Reputation: 13853
I've grabbing the URL of a thumbnail when clicking on it and adding it to another image in the HTML:
$('#result .thumb').live('click', function() {
var newImgSrc = this.src;
$("#thumbnail").attr("src", newImgSrc);
});
However I want to alter the URL that gets sent, it currently looks something like:
...com/4100/5412955054_45ce3a897e_s.jpg
I want to remove _s
from the very end of the URL. Can I do this in jQuery or Javascript?
Upvotes: 0
Views: 208
Reputation: 19557
Yes, use replace() function.
newImgSrc = newImgSrc.replace(/_s\.jpg/,'.jpg');
Upvotes: 1