For the last few hours I have scoured for a way to do this and have com up with nothing. I am trying to figure out a way to change only a sub string within an attribute. An example of what I would like to do is change
<a href="media/gallery/jtnp/JT.JPG" rel="shadowbox[JTNP]" title="Joshua tree" class="shaddowimages"><img id="JTth" src="media/gallery/jtnp/b_thum/JTthumb.JPG" alt="A small Joshua tree"></a>
to
<a href="media/gallery/jtnp/JT.JPG" rel="shadowbox[JTNP]" title="Joshua tree" class="shaddowimages"><img id="JTth" src="media/gallery/jtnp/s_thum/JTthumb.JPG" alt="A small Joshua tree"></a>
Here is what I have so far, however nothing happens when I attempt to press the button #changethumb.
$(document).ready(function() {
var count = 0;
$('#changethumb').click(function() {
if (count === 0) {
$('#shaddowimages img').each(function() {
$(this).attr('src', $(this).attr('src').replace('b_', 's_'));
});
count = 1;
} else {
$('#shaddowimages img').each(function() {
$(this).attr('src', $(this).attr('src').replace('s_', 'b_'));
});
count = 0;
}
})
});
I could go through and replace each src manually, but having 20+ images, I would like a way to automate this if I could. Any help?