hiding li of a tree,using jQuery works in firefox but not in IE8
I am using jQuery to show and hide li elements of a tree(tree is build using ul and li elements ) based on some condition. here is my code.
function filterLeftNavTree(filterData){
if(filterData.indexOf("|")!=-1){
$("ul.treeview").find("li").hide();
var filterData = filterData.split("|");
for(i=0;i<filterData.length;i++){
$("ul.treeview").find("li").filter(":contains(\'"+filterData[i]+"\')").show();
}
}else{
$("ul.treeview").find("li").hide().filter(":contains(\'"+filterData+"\')").show();
}
}
in this function what i am doing is, passing data which can be string seperated by | . then first hiding all li, then showing only tjose li which matched to string passed to
function. this function is working fine in Firefox but not in IE8. any one can please tell me why? any alternate solution is also good for me. guys plz help me 开发者_开发技巧out.thanks
viveki Solved this problem. Actually, while picking data in filterData, it picks spaces too. and filter function is case-sensitive, so its not working in ie8. i just trimed those spaces and its working fine in ie8.
if(filterData.indexOf("|")!=-1){
$("ul.treeview").find("li").hide();
var filterData = filterData.split("|");
for(i=0;i<filterData.length;i++){
$("ul.treeview").find("li").filter(":contains(\'"+filterData[i].trim()+"\')").show();
}
}else{
$("ul.treeview").find("li").hide().filter(":contains(\'"+filterData.trim()+"\')").show();
}
any way, thanks to all of you.
Vivek
精彩评论