Why trigger fired only once when running on a JQuery Object?

Posted by Shlomi.A. on Stack Overflow See other posts from Stack Overflow or by Shlomi.A.
Published on 2010-04-15T21:47:56Z Indexed on 2010/04/15 21:53 UTC
Read the original article Hit count: 339

Filed under:
|

Hi I got an array. I'm running over it

for (i = 0; i < sugestionsArray.length; i++) {
            $('li.groupCode' + sugestionsArray[i] + ' span').addClass('checkedInput');
            $('option[value=' + sugestionsArray[i] + ']').attr('selected', 'selected');

        }

And this loop runs 3 times perfectly, adding classname and playing with the option. instead of adding a clasname, i'm trying to trigger a click over the span

$('li.groupCode' + sugestionsArray[i] + ' span').trigger('click');

which in his turn has a click event bind to it using jq as well

Span.click(function() {})

for some reason my loop breaks after the first click. he is leaving the loop and don't continue to the next 2 loops after him. only the first span is been clicked.

does anyone has an idea?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about trigger