html5 实现输入框实时搜索




function searchText(){
var content ="";
var inputVal=$('#siteInput').val();
var siteNum = {'张三':"桌1", '李四':"桌2"};
var found = false;
for( var key in siteNum){
if(key == inputVal) {
content = siteNum[key];
found = true;
}
}
if(!found && inputVal != "") {
content = '未找到';
}
$('#siteSearch>p').text(content);
}

this.initSearchSite=function() {
$("input:text").bind("input propertychange",function(){
searchText();
});
}


你可能感兴趣的:(html5)