I have the image name in a variable and want to replace it but not sure how to do this.
Currently I can replace the image src with: var new_src = $(this).attr("src").replace(/ship.png$/i, fileObj.name); I want to do something like this (which doesn't work): var new_src = $(this).attr("src").replace(imagename, fileObj.name); Any help is appreciated. Chris