Bruno
Bruno

Reputation: 1

jQuery :contains in a variable and for loop

i have this:

for(y=0; y<numbers_sold.length; y++){
    $("#stickers a:contains('" + numbers_sold[y] + "')").addClass('sold');  
}

It doesn't work. If substitute the variable numbers_sold by a number it works... Can you help?

Thanks.

Upvotes: 0

Views: 477

Answers (2)

Mahesh
Mahesh

Reputation: 2256

what is here not working? It works for me. see http://jsfiddle.net/3Du3K/

Upvotes: 1

Doug
Doug

Reputation: 264

Have you tried something like this?

    $.each(numbers_sold, function(i, val){
    $("#stickers a:contains('" + val + "')").addClass('sold');
});

Upvotes: 0

Related Questions