0
我想检查文件名变量是否为空。我使用jquery if statement issue
$.each(rows, function(rowIndex, row){
var fileName = $.trim(fields[0]).toLowerCase();
//will output fileName
console.log(fileName);
//out -1,5,3,15,15,5,5,6,7,-1,3,5,5
console.log(fileName.indexOf('.html'));
if(fileName.indexOf('.html') < 0 || window.location.href.toLowerCase().indexOf(fileName) < 0) //invalid or different file, skip this row
{
//if the filename is empty skip this loop and check next loop filename variable
return true;
}
//the above script is to check to see if the filename is empty.
var $element = $('#' + fileName);
//doesn't show anything at all.
console.log(fileName);
})
我的'if'语句之前的所有内容都会显示,但不会显示在它之后。
感谢您的帮助。
而不是'return true;',只是使用'return;'。 – ahren 2012-08-13 21:45:17
放置一个'console.log()'_inside_ if语句 - 如果if条件为true,则该函数根据代码中的注释停止该点。在这种情况下'$ .each()'的目的是什么?回调中的任何地方都没有使用'rowIndex'或'row'。 '行'中有什么? 'fields'定义在哪里? – nnnnnn 2012-08-13 21:49:40