When hovering the .f_bb
div, it should simply show up .f_bloc
and add a class to it. When the hovering is over (when the cursor is out of it), it should fade out and hide. But I can't make it work, for some reason.
HTML
<div id="fc3"><div class="f_bb">test
<div class="f_bloc">roat</div></div></div>
CSS
.test {color: red}
.f_bloc {display: none}
JS
$(document).ready(function() {
$("#fc3 .f_bb").onmouseenter(function() {
$(this).closest(".f_bloc").show();
$(this).closest(".f_bloc").addClass("test");
});
});
$(document).ready(function() {
$("#fc3 .f_bb").onmouseleave(function() {
$(this).closest(".f_bloc").fadeOut( 1000, function() {
$(this).closest(".f_bloc").hide();
});
});
});
Jsfiddle : https://jsfiddle.net/ebcm08tL/ UPDATED https://jsfiddle.net/ebcm08tL/2/
The problem is that you used
.closest()
method. With.children()
method works fine to me, and you also have to include jquery if you didn't.