Is there a way to narrow it down by element attributes in jquery?

Asked 2 years ago, Updated 2 years ago, 51 views

html

<a href="hoge">1</a>
<a href="huga">2</a>
<a href="hogehoge">3</a>
<a href="hugahuga">4</a>

jquery

$('a').onAttr('href', 'hoge'); // 1 jquery object
$('a').onAttr('href', 'huga'); //2 jquery object
$('a') .onAttr('href', /hoge/); //1,4 jquery objects
$('a') .onAttr('href', /huga/); // jquery object for 2, 3

I'd like to get the elements that 'href' matches like this, but what should I do?
All I can think of is to get a and turn it around with each to check...

javascript html jquery

2022-09-30 19:54

1 Answers

user7339 Comments:

It's solved.Thank you. $('a[href*="partial match"]')


2022-09-30 19:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.