Hussein
Hussein

Reputation: 42818

jquery referencing multiple elements in one line

How can i write this in one line.

$('#id').whatever();
$('#id1').whatever();
$('.class').whatever();

Upvotes: 7

Views: 3551

Answers (1)

Phrogz
Phrogz

Reputation: 303421

As with CSS, you can use commas to join together multiple distinct selectors:

$('#id, #id1, .class').whatever();

Upvotes: 11

Related Questions