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?

Answers


Maybe something like that?

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

Need Your Help

$("...")[0].reset is not a function... resetting forms in jQuery

jquery forms reset

I'm trying to reset some forms with jQuery but I'm having some trouble. Aside from solutions that involve writing functions or custom plugins, I keep finding time and again that the reset method i...