I have the following hover function
function tt_attachToBase(){
jQuery.each(bases,
function(index,base){
jQuery(base).hover(function() {
jQuery(base).showTipTimer = setInterval( function(){tt_locateBase(base);} , 3000 );
},
function() {
clearInterval(jQuery(base).showTipTimer);
tt_hideTip();
}
});
}
);
inside tt_locateBase() I also clear interval like this
tt_locateBase(base){
clearInterval(jQuery(base).showTipTimer);
//code to sidplay tooltip
}
the tooltip does display after an interval, but the interval it seems is never cleared since the tooltip keep recurring over base. what am I doing wrong?
Setting a property to the return value of
jQuery(base)will only affect that specific object. If you fetchjQuery(base)a second time it won’t be carrying that property.What you’re currently doing is equivalent to the code below:
Solution
Attach it as a data field instead, perhaps? This way, it will affect the actual object in the DOM, and the jQuery object will carry that data value in subsequent fetches.
Then clear with: