Is there any syntactic sugar to find the element by its attribute in jQuery?

Quite often you need to select an element based on its attribute, or attribute value.
The result is written something like $someEl.find('a[href="'+someVar+'"]'), and seems to be nothing but a piece +'"]') leads me to certain thoughts. When there are two consecutive attribute, all tin comes out.

I would like to see something like $someEl.find('a').where('href',someVar).
PS: plus, how to deal with data-attributes. Using $el.data() they are not set into the DOM like this?
P. P. S.: Yes, you can write a bike, like .toggleClass(), but it is more difficult, I think.
July 12th 19 at 17:05
3 answers
July 12th 19 at 17:07
I would like to see something like $someEl.find('a').where('href',someVar).
Write a small plugin that adds the sugar that is right for you, it is very easy now.

Using $el.data() they are not set into the DOM like this?
To use an additional $el.prop().
July 12th 19 at 17:09
Use Babel, Luke
$someEl.find(`a[href="${href}"]`)
July 12th 19 at 17:11
PS: plus, how to deal with data-attributes. Using $el.data() they are not set into the DOM like this?

RTFM.
$elem.attr('data-foo', 'bar');

No not the tin. Use Babel, or if it's all hard, then maybe it's not your niche?
Oh, and I did not think that you can through $elem.attr() to do. You're smart and well done. - Molly_Corwin commented on July 12th 19 at 17:14

Find more questions by tags JavaScriptjQuery