Blynn
Blynn

Reputation: 1421

jQuery define two elements in one variable

Is there a way to define two elements in one variable.

For example:

var replacer = $(".ir a") && $(".tk a");

Upvotes: 0

Views: 1826

Answers (1)

David Thomas
David Thomas

Reputation: 253416

var replacer = $('.ir a, .tk a');

Or:

var replacer = $('a').filter(function(){
                   return $(this).closest('.ir').length ||  $(this).closest('.tk').length
               });

References:

Upvotes: 4

Related Questions