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 ?
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 ?
Use the attribute starts with selector to get just those IDs:
$('li[id^="item"]').removeClass('test'); $(youritem).removeClass('test'); I believe you would need a ^= selector on the element.
$('li[id^=item]').removeClass('test'); Check the jsfiddle
If you want to use regex expressions in your jQuery selectors, check out this plugin: http://james.padolsey.com/javascript/regex-selector-for-jquery/
In this context it would be something like:
$('.test:regex(id, ^item([0-9]+)$)').removeClass('test');