gremo
gremo

Reputation: 48899

jQuery multiple attribute selector with logic OR, shortcuts?

Select all elements with data-toggle attribute no matter value and with (href="#myModal" or data-target="#myModal").

I've used this:

$('[data-toggle][href="#myModal"], [data-toggle][data-target="#myModal"]');

Not DRY. Is there any simple method or function to do this?

Upvotes: 9

Views: 9580

Answers (1)

VisioN
VisioN

Reputation: 145398

Maybe something like that?

$("[data-toggle]").filter("[href='#myModal'],[data-target='#myModal']");

Upvotes: 27

Related Questions