好的,我有代码:
$( function() {
$('#questionSearchInput').keyup(function(){
var list = [];
search = $(this).val().toString();
searchArray = search.split(" ");
console.log(searchArray);
$.each(grabbedItems, function(j, question){
question.score = 0;
console.log(question.score);
});
if(searchArray[0]){
$.each(grabbedItems, function(i, question){
lowerName = question.name.toLowerCase();
if(lowerName.indexOf(searchArray[0]) > -1){
question.score = question.score + 1;
console.log(question.score);
}
});
}
if(searchArray[1]){
$.each(grabbedItems, function(i, question){
lowerName = question.name.toLowerCase();
if(lowerName.indexOf(searchArray[1]) > -1){
question.score = question.score + 1;
console.log(question.score);
}
});
}
}
grabbedItems.sort(function(a, b){
return b.score - a.score;
});
if(grabbedItems.length < 1){
document.getElementById("noQuestionsP").style.display = "block";
}
clearBox("questionNamesDisplay");
$.each(grabbedItems, function(k, question){
if(k < 5){
var place = document.getElementById("questionNamesDisplay");
var item = document.createElement("a");
item.innerHTML = question.name;
item.href = question.link;
item.style.display = "block";
place.appendChild(item);
}
});
});
});
在此函数执行之前,通过post请求检索var grabbedItems。控制台日志显示它是准确的。
我的问题是这个功能实际上在我的笔记本电脑上运行正常,但是当我在我的iphone上运行时,该功能无法正常运行。我无法诊断它有什么问题。但它不能正常运作。有没有人对我如何诊断它有什么问题的新手有任何建议。