one way to approach what you're trying to do is with a simple
setInterval (http://developer.mozilla.org/index.php?title=En/DOM/
Window.setInterval), so that the parser has a bit of breathing room
between calls to someFunc.

if you just loop through, you're essentially saying "call someFunc as
many times as you can, as fast as you can possibly call it", which
isn't really cpu-friendly ;)

try this instead:

var int = null;
$('#element').hover(function() {
  int = setInterval(someFunc, 100);
}, function() {
  clearInterval(int);
});

-micah

On Aug 29, 2:00 pm, Leanan <[EMAIL PROTECTED]> wrote:
> Hey guys.
>
> I've poured over the docs, and mouseover/hover/etc only trigger once.
> I want it to continue to trigger a function while the element is
> hovered.
>
> I've tried:
>
> $('#element').hover(function() {
>   while(true) {
>     someFunc;
>   }
>
> }, function() {});
>
> Unfortunately, this screws things up.  The while loop hangs the
> browser for a while before it finally throws the "this script has been
> running too long" message.
>
> I've tried looking at some of the scrolling plugins to see how they do
> it but the only one I can find that seems to have this functionality
> (do something while hovering over an element, in this case, continue
> scrolling) has no documentation, and the examples do not explain how
> to use the plugin, they merely show it working.  What little bit of
> text is on the page is non-english and from the looks of it is little
> more than headers anyway, so useless even if I translated it.
>
> So, how should I go about continuing to trigger someFunc while I'm
> hovered over a particular item on the page?

Reply via email to