2013-02-16 30 views
0

下面的代碼是通過全部div內的inputselect元件循環和檢查該值是空的,然後隱藏它,它可以正常使用:循環通過輸入和選擇元件和隱藏先前TD

$("#customfields_1 :input").filter(function() { 
    return $.trim(this.value).length === 0; 
}).hide(); 

但現在我真正想要的是隱藏以前td,是這樣的:使用前

$("#customfields_1 :input").filter(function() { 
    return $.trim(this.value).length === 0; 
}).prev('td').hide(); 

回答

1

我想你想.parent('td').hide();.closest('td').hide();

1

遍歷到td 210。

.closest("td").prev("td").hide(); 

和審查DOM traversal API從jQuery的。

+0

這絕對是我所需要的,TNK你 – user2077308 2013-02-16 01:42:03

+0

@ user2077308 - 那麼你應該接受這個答案! – adeneo 2013-02-16 01:54:20