views:

50

answers:

0

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?