表中的行显示/隐藏-remove()

Table rows show/hide - remove()

本文关键字:隐藏 -remove 显示      更新时间:2023-09-26

我的问题是,为什么我不能使用hide()&show()在我的网页上隐藏/显示表格行。如果我使用其中任何一个,浏览器都会冻结,但如果我使用remove(),它可以正常工作,但我无法收回这一行(或?)。

如果我在任何其他事情上使用显示和隐藏,它的工作就很好。我做错了什么?

    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;}
    }

编辑:

我使用了live(),正如我刚才读到的,toggle等在live()中不起作用。。。但我仍然需要答案:(

$("#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是一个div,我在它上面附加了特定<td>.text(),我希望当我点击它时,它会删除这个td:table行的父行。它适用于remove()。。。

独奏:

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);
        }
    }
})