当类别适用于其他5个div时,如何在鼠标悬停时仅淡入1 div? [英] How can I fade only 1 div on mouseover when the classes applies to 5 other divs?
本文介绍了当类别适用于其他5个div时,如何在鼠标悬停时仅淡入1 div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$("div.test").mouseenter(function() {
$("div.innerDiv").fadeIn("slow");
}).mouseleave(function() {
$("div.innerDiv").fadeOut("slow");
});
<div class="test">
<div class="innerDiv">1</div>
</div>
<div class="test">
<div class="innerDiv">2</div>
</div>
<div class="test">
<div class="innerDiv">3</div>
</div>
<div class="test">
<div class="innerDiv">4</div>
</div>
因此,当前的行为方式是,如果我将鼠标悬停在任何div上,则所有div都会淡入.我只希望悬停的div淡入,而不是全部都淡入.我认为有一种方法可以在不更改div结构的情况下更改jQuery,但我不知道怎么做.
So how this currently behaves right now is that if I mouseover any of the divs then all of them would fade in. I want only the div that I hover over to fade in and not all of them. I think there is a way to change the jQuery without changing the structure of my div, but I don't know how.
推荐答案
在这里.
$("div.test").mouseenter(function() {
$('div.innerDiv',this).fadeIn("slow");
}).mouseleave(function() {
$('div.innerDiv',this).fadeOut("slow");
});
这篇关于当类别适用于其他5个div时,如何在鼠标悬停时仅淡入1 div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文