标签:style back search inpu 查找 input val htm color
//模糊匹配
check.onclick = function(){
for(i = 0;i<ul.children.length;i++){
var list = ul.children[i].innerHTML;
var inputValue = inPut.value;
if(list.search(inputValue) != -1){
ul.children[i].style.background = ‘yellow‘; // 注意这里不可以再用list这个变量了,也不能是innerhtml了,不然搜索不到。
}else{
list[i].background = ‘‘;
}
}
}
//多关键词查找
check.onclick = function(){ for(i = 0;i<ul.children.length;i++){ var list = ul.children[i].innerHTML; var inputValue = inPut.value; var gdhs = inputValue.split(‘ ‘) //list.match(gdhs); for(j = 0;j<gdhs.length;j++){ if(list.search(gdhs[j] !=-1)){ ul.children[i].style.background = ‘yellow‘; }else{ ul.children[i].style.background = ‘‘; } } } }
//match匹配 多关键词查找
check.onclick = function(){ for(i = 0;i<ul.children.length;i++){ var list = ul.children[i].innerHTML; var inputValue = inPut.value; var gdhs = inputValue.split(‘ ‘) //list.match(gdhs); for(j = 0;j<gdhs.length;j++){ if(list.match(gdhs[j])){ ul.children[i].style.background = ‘yellow‘; }else{ ul.children[i].style.background = ‘‘; } } } }
lhdfgdsa
标签:style back search inpu 查找 input val htm color
原文地址:http://www.cnblogs.com/Jerry-spo/p/6565062.html