prepend href with same class

Posted by user357034 on Stack Overflow See other posts from Stack Overflow or by user357034
Published on 2010-06-03T01:48:15Z Indexed on 2010/06/03 1:54 UTC
Read the original article Hit count: 304

Filed under:

I have the following code on the my page...

<a href="javascript:change_product_photo(2);"><img id="alternate_product_photo_2"    style="border-color:#666666;" src="/v/vspfiles/photos/00-6189-2S.jpg" border="1">

Sometimes there could be more of the <a href="javascript:change_product_photo(4);"> and each one would have a higher index number 5, 6 ,7, etc.

What I want to do is for each and every instance of the href with javascript:change_product_photo(x) (where x is the index) remove both "_" from the change_product_link but leave the (x) index

My thought was to first add a class to all hrefs that contain javascript:change_product_photo and then modify all of the href;s with that class but I am lost on how to do this.

Here is what I got so far...

$("a[href*='javascript:change_product_photo']").addClass('link_fix');

Now I don't know how to remove the "_" from the url.

© Stack Overflow or respective owner

Related posts about jQuery