My question is, why I can not use hide()
& show()
to hide/show table rows on my web page. Browser freezes if I use any of those, but if I use remove()
it works fine, but then I cannot get this row back(or?).
If I use show and hide on any other thing's it work's just fine. What did I do wrong?
for(var i=0; i<=pages-begin; i=i+1){
if($("#myTable2 tr:nth-child("+i+") td:nth-child("+ rowIndex +")").text() == $(this).text()){
$("#myTable2 tr:nth-child("+i+") td:nth-child("+ rowIndex +")").parent().remove(); i=i-1;}
}
EDIT:
I used live()
, and as I read just now toggle and such do not work inside live()
... but I still need answer :(
$("#dropMenuFilter ul li").live("click", function(){
for(var i=0; i<=strani-zacetek; i=i+1){
if($("#myTable2 tr:nth-child("+i+") td:nth-child("+ rowIndex +")").text() == $(this).text()){
$("#myTable2 tr:nth-child("+i+") td:nth-child("+ rowIndex +")").parent().fadeOut(); i=i-1;}
}});
dropMenuFilter is some div, on which I append .text()
of specific <td>
and I wish, that when I click on it, it will remove parent of this td: table row. It works with remove()
...
soloution:
function removeRow(vrstica){
$("#myTable2 tr:nth-child("+vrstica+") td:nth-child("+ rowIndex +")").parent().toggle();
}
$("#dropMenuFilter ul li").live("click", function(){
for(var i=1; i<=strani-zacetek; i+=1){
if($("#myTable2 tr:nth-child("+i+") td:nth-child("+ rowIndex +")").text() == $(this).text()){
removeRow(i);
}
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.