내 JQuery와 모바일 페이지에 검색 기능을 만들려고 노력하고,검색 상자 jQuery를 모바일
HTML은 :
<input type="search" placeholder="Search" id="searchbar" />
<ul data-role="listview" id="searchlist"></ul>
사용자가 검색되기 때문에, 결과는리스트 뷰에 추가됩니다.
검색 창에 글자를 입력 할 때마다 다음 코드를 실행하고 싶습니다. 어떻게해야합니까?
if (searchbar.val().length > 2)
{
$.ajax({
url: "http://clubbedin.zymichost.com/search.php",
type: "post",
crossDomain: true,
data: {
'q': value,
'userID': userID
},
success: function(data) {
var json = jQuery.parseJSON(data);
for (var i = 0; i < json.length; i ++)
{
html += '<li><a data-option-id=\"' + json[i].optionid + '\">' + json[i].optionname + '</a></li>';
}
$('searchlist').append(html);
$('searchlist').listview("refresh");
}
});
}
도움이 되겠습니다. 감사!
작품을 마법처럼, 덕분에 다시 한번 @hungerpain – nshah