Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有多个 li 元素,我希望仅在我悬停的 li 上发生切换淡入淡出。目前,下面的代码将针对所有这些。
我知道我需要在某处添加“this”,但我尝试过的一切都不起作用。
这是我有问题的 jQuery 代码:
$('li.featuredItem').hover(function() { $('li.featuredItem figcaption').fadeToggle('400'); });
谢谢,杰克
使用$(this), 指的是当前element, 包裹在一个jQuery object.
$(this)
element
jQuery object
$('li.featuredItem').hover(function() { $(this).fadeToggle('400'); });
$('li.featuredItem').hover(function() { $(this).find('figcaption').fadeToggle('400'); });