Skip to content Skip to sidebar Skip to footer

Javascript Replacing Strings

I have a small custom made thumbnail gallery. On click of a thumbnail I want to get the bigger version of the image. To do this I am getting the img's src. With that I want to repl

Solution 1:

Simply use the JS replace() function:

var imgSrc = "/media/uploads/headshots/width_60_259850_10150280251835435_717615434_9570015_4084479_n.jpg"var newSrc = imgSrc.replace("width_60_", "width_104_");

Here's a working jsFiddle.

Post a Comment for "Javascript Replacing Strings"