0 Replies - 581 Views - Last Post: 19 August 2011 - 10:36 PM

#1 kabuto178   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

problem with mouseenter function

Posted 19 August 2011 - 10:36 PM

$(document).ready(function(){
        //pause chat updating while hover
	var auto_refresh = 0;
	$("#load_tweets").mouseenter(function() {
	auto_refresh = window.clearInterval(auto_refresh);
	auto_refresh=0;
	}).mouseleave(function(){
     auto_refresh = window.setInterval('displayMessages()', 2000);
  });
});

the above is my code which i use to update a DIV element with a simple setineterval when the mouse is not on the div and it should clear the interval when the mouse is on the element. It does work, but is kinda qwerky as in sometimes it ignores the clearing until the page is refreshed or some time has passed I was wondering if there is a better way to do this, or a smoother way to get this done.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1