I am trying to reset a class for any links that have been previously selected by removing the end of a class name.
When the link is clicked on the class is appended with “_selected” so that the image remains highlighted. When another link is clicked on, I am trying to remove “_selected” from any link that may have been selected previously (many rollovers on the page).
Seems like the following should work:
$(‘a’).attr(‘class’).replace(/_selected/g, ”);
Doesn’t this look for all links with classes and replace instances of “_selected” with nothing?
Is there a better way to look at this? New to jQuery… Thanks
You can put more than one classes in an element, like:
So, with jQuery:
and of course previously you have added it with
And you need to define it, of course
Not exactly what you want, but I think it is what you need 🙂
In fact, what you want is: