Why is setTimeout () with 0ms. affects my function
In my case on hover <div>
so add one element inside<div>
But in some div I want to hide the added element after hovering the element.
This is my code and it works!
HTML:
<div class="one">
<span class="content"></span>
</div>
<div class="two">
<span class="content"></span>
</div>
jQuery:
$("div.one > .content").on("hover" , function(){
var this_ = $(this);
this_.prev(".top").remove();
});
$("div.two > .content").on("hover" ,function(){
var this_ = $(this);
setTimeout(function(){this_.prev(".top").remove();})
});
.one
and .two
both are the same function. But I want to know why the second function affects usage setTimeout()
and the time is 0 milliseconds, Why is 0 millisecond affected in my function?
+3
source to share
2 answers