I want that if i hover on a div then add abc class in rest div
.abc{
color:Red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
<h2>h2</h2>
<p>p</p>
</div>
<div>
<h2>h2</h2>
<p>p</p>
</div>
<div>
<h2>h2</h2>
<p>p</p>
</div>
I want to use jquery traversing for this code
I guess this will help you.
$("div").hover(function() {
$(this).siblings("div").addClass("abc");
}, function() {
$(this).siblings("div").removeClass("abc");
});
.abc{
color:Red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
<h2>h2</h2>
<p>p</p>
</div>
<div>
<h2>h2</h2>
<p>p</p>
</div>
<div>
<h2>h2</h2>
<p>p</p>
</div>