Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery regexp selector

Tags:

jquery

I have a simple example:

<li id="item0" class="test"> 
    .....
<li id="item10" class="test"> 

How to remove class "test" from all elements this id =~ "#item\d{1,}" using jquery ?

like image 210
Bdfy Avatar asked Jul 06 '26 04:07

Bdfy


2 Answers

Use the attribute starts with selector to get just those IDs:

$('li[id^="item"]').removeClass('test');
like image 131
Blazemonger Avatar answered Jul 08 '26 17:07

Blazemonger


$(youritem).removeClass('test');
like image 44
Rob Avatar answered Jul 08 '26 17:07

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!