When you call activate() inside the click handler, you add one more
event listener for the click, which calls activate() again and so on.
You should either not call the function from within itself or move the
bind() outside.

On May 18, 9:29 am, Dmitri <smirnov.dmi...@gmail.com> wrote:
> I have a function
>
> caps = []; /* some array */
> function activate()
>     {
>       var index = parseInt(Math.random() * caps.length);
>
>       if( caps.length > 0) {
>         caps[index].addClass("active");
>         $("#tip").html(caps[index].html());
>       } else {
>         win();
>       }
>
>       $("a.active").bind("click", function() {
>         var cap = $(this);
>         $(this).fadeOut("fast", function() {
>           cap.replaceWith("");
>         });
>         caps.splice(index, 1);
>         activate();
>
>         return false;
>       });
>
>       return;
>     }
>
> it's simple  when you click on <A> tag with active class something is
> happing.
> The problem is that ONLY Internet Explorer calls this function
> recursively in infinite loop, why??? Lost half of the day.

Reply via email to