似乎无法弄清楚这一点,感觉我在这里错过了一些愚蠢的东西......
基本上,当将鼠标悬停在删除链接上时,我试图对该行中的所有文本进行换行,除了其中的<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');