Andrew
Andrew

Reputation: 509

Use array to store jQuery Selectors

I'd like to be able to have an array full of jQuery selectors as such (an array of class names). This is what I'm doing at the moment though it's not functioning:

var array = [$('.one'),$('.two')];
array[0].find('.box-text').attr('src',"myImage.png");

What's wrong?

Upvotes: 0

Views: 1397

Answers (1)

Hussein Nazzal
Hussein Nazzal

Reputation: 2557

is it ok for you to do something like

var array = ['.one','.two'];
$(array[0]).hide()

Upvotes: 5

Related Questions