Reputation: 871
i have a small Tooltip Script when the user hover a block the Tooltip will be shown and if the user leave the block the tooltip is hidden.
But i want also when the user hover over the tooltip the tooltip stay until the user leaves the tooltip or the hover block.
here is my javascript without the hover over the Tooltip:
$( "#hover, .tooltip" ).on('mouseenter', function() {
$( ".tooltip" ).fadeToggle( 400, function() {
// Animation complete.
});
});
$( ".tooltip, #hover" ).on('mouseleave', function() {
$( ".tooltip" ).fadeToggle( 400, function() {
// Animation complete.
});
});
Here is a small Fiddle without the second part: http://jsbin.com/vocirucawoje/1/edit
Upvotes: 0
Views: 3092
Reputation: 325
<input type="button" class="hover" value="Click" />
<div class="tooltip" style="display:none;">Tool tip Text</div>
$('.hover').mouseenter(function () {
$(".tooltip").stop().fadeToggle(400, function () {
// Animation complete.
});
});
$('.tooltip').mouseleave(function () {
$(".tooltip").fadeToggle(400, function () {
// Animation complete.
});
});
It will help you.
Upvotes: 1
Reputation: 76
use stop() to stop the animation.
$( "#hover, .tooltip" ).on('mouseenter', function() {
$( ".tooltip" ).stop().fadeToggle( 400, function() {
// Animation complete.
});
});
$( ".tooltip, #hover" ).on('mouseleave', function() {
$( ".tooltip" ).stop().fadeToggle( 400, function() {
// Animation complete.
});
});
Upvotes: 2