我觉得我必须使用太多的.children()在我的一些jQuery函数。
这是我的HTML:
<div class="goal-small-container">
<div class="goal-content">
<div class="goal-row">
<span class="goal-actions">
这是我的jQuery:
$('.goal-small-container').hover(function() {
$(this).children('.goal-content').children('.goal-row').children('.goal-actions').css({visibility: "visible"});
},function () {
$(this).children('.goal-content').children('.goal-row').children('.goal-actions').css({visibility: "hidden"});
});
有没有更好的办法?告诉我孩子们
解决方法
.find('.goal-content .goal-row .goal-action').whatever()
或更简单地:
.find('.goal-action').whatever()