淘先锋技术网

首页 1 2 3 4 5 6 7

$("#searchKey").keydown(function(event) {

var searchKey=$("#searchKey").val();

if (event.keyCode == 13 && searchKey!="") {

var i=0;

$("#roomTree > li > ul > li").each(function(idx,obja){ //成都

i=0;

if(i==0){

$(obja).css("display","none");

}

$(obja).find("> ul > li").each(function(idx,objb){ //区县

i=0;

if(i==0){

$(objb).css("display","none");

}

$(objb).find("> ul > li").each(function(idx,objc){ //局站

$(objc).css("display","none");

// console.log($(objc).children("a").children("cite").text().indexOf("张家"))

// console.log($(this).children("a").children("cite").html())

if($(objc).find(" > a > cite").text().indexOf(searchKey) >= 0){

$(obja).css("display","block");

$(objb).css("display","block");

$(objc).css("display","block");

i++;

}

});

});

});

//全部展开

$("#roomTree li ul").attr("class","layui-show");

$("#roomTree li ul").find("ul").each(function(idx,obj){

$(this).attr("class","layui-show");

});

}

if (event.keyCode == 13 && searchKey=="") {

$("#roomTree > li > ul ").find("li").each(function(idx,obja){

$(obja).css("display","block");

});

//不展开

$("#roomTree li ul").find("ul").each(function(idx,obj){

$(this).attr("class","");

});

}

});

注意:本文归作者所有,未经作者允许,不得转载