似乎無法弄清楚這一個,覺得我失去了一些東西愚蠢這裏....filter(),那麼僅適用於特定的。孩子()
基本上當徘徊在刪除鏈接,我試圖做一個線通過該行中的所有文本,除了<td>
在它那<a class="remove">
。
基本HTML結構是:
<tr>
<td>Lorem ipsum text here</td>
<td>01/01/2012</td>
<!-- all <td>'s except for the Remove one should get a line-through -->
<td><a class="remove">Remove</a></td>
</tr>
的jQuery:
$('tr').on({
'mouseover' : function() {
$(this).closest('tr').find('td').filter(function() {
var $childElems = $(this).children();
// I can see the <a class="remove"> in .children()
// But for some reason can't just test (hey there's an <a>,
// then don't apply this)
if ($childElems.find('a').length <= 0) {
return $(this).css('text-decoration', 'line-through');
}
});
},
'mouseout' : function() {
$(this).closest('tr').find('td')
.css('text-decoration', 'none');
}
}, 'a.remove');
啊沒用過'.filter()'很多,應該是我想這一切都是錯的!感謝馬特,馬上清理它。 – 2013-03-20 15:59:52