似乎无法弄清楚这一个,觉得我失去了一些东西愚蠢这里....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