[英]Table rows show/hide - remove()
我的問題是,為什么我不能使用hide()
和show()
來隱藏/顯示網頁上的表行。 如果我使用其中任何一個,瀏覽器都會凍結,但是如果使用remove()
,瀏覽器將正常工作,但隨后我將無法返回該行(或?)。
如果我在其他任何東西上使用show and hide則可以正常工作。 我做錯了什么?
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()
,正如我剛才所讀的那樣,切換功能在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:表行的父級。 它適用於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);
}
}
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.