파일 이름 변수가 비어 있는지 확인하려고합니다. 나는 'if'진술이 나타나기 전에 모든 것을 나타낼 것이지만 그 후에는 나타나지 않을 것입니다.jquery if 문 문제
$.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);
})
도움 주셔서 감사합니다.
대신'return true;를 사용하고,'return;'만 사용하십시오. – ahren
'console.log()'를 넣는다 if 문 - if 조건이 참이면 코드의 주석에 따라 그 시점에서 함수가 멈춘다. 이 경우'$ .each()'의 목적은 무엇입니까? 당신은 당신의 콜백 어디에서나'rowIndex' 나'row'를 사용하지 않습니다. 행에 무엇이 있습니까? 'fields'는 어디에 정의되어 있습니까? – nnnnnn