Looking to create an effect where a tooltip appears when hovering over an element and then disappears after a few seconds, even if the mouse is still on the element. Here is my current code:
<div data-sentence-tooltip="yes" data-tooltip-content: "some content"> some text </div>
$('[data-sentence-tooltip="yes"]').tooltip({title: function(){return $(this).attr('data-tooltip-content')}});
I have tried a couple of solutions found in related SO questions:
setTimeout(function(){$(".tooltip").fadeOut("fast");}, 2000);
and
jQuery.fn.delay = function(time,func){
return this.each(function(){
setTimeout(func,time);
});
};
$('[id^="tooltip"]').delay(2000, function(){
$('[id^="tooltip"]').fadeOut('fast');
}
);
However, I suspect these are not working because the .tooltip
or id=tooltip*
elements are added dynamically to the DOM.
References:
- jQuery tooltip, hide after.. time
- jquery tooltip set timeout