0
I am wearing one tooltip plugin
in jQuery to modify attributes title=""
multi-class. Everything was going fine until I realized a problem - I’m using a button that changes class as it’s clicked, and when this button changes class the tooltip stops working.
Obviously I tried to add to class
of the button to which it is changed after being clicked to the same function as the tooltip
in Javascript, but this did not work.
So my solution to this was to use a setInterval()
to run this function of x
in x
time for the tooltip to start working again after the class of this button has been modified.
But now I have 2 questions:
When we use the
setInterval()
the request for this function is being sent to the server each time it tries to run again, or it is just running on its own Browser Window where the user has?
(This is a concern related to Bandwidth server)I searched and found another way to constantly perform this function using
setTimeout
who say is a better way to approach the same.
So which of these two solutions will be the best solution to address this and what is the difference between the two?
// setTimeout
(function loopingFunction() {
$('.like-button').tipsy({fade: true, gravity: 'w'});
setTimeout(loopingFunction, 500);
})();
// setInterval
setInterval(function(){
$('.botao-gosto').tipsy({fade: true, gravity: 'w'});
}, 500);
Along with my question here is also an example in Jsfiddle if you can help: http://jsfiddle.net/jdbe0fL7/
setTimeout
would just be a delay, already setInterval is a continuous repetition with delay.– Guilherme Nascimento