Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 584
gremo Avatar asked Jul 18 '12 21:07

gremo


1 Answers

Maybe something like that?

$("[data-toggle]").filter("[href='#myModal'],[data-target='#myModal']");
like image 110
VisioN Avatar answered Nov 10 '22 04:11

VisioN