What I'm trying to do is replace some a bit of "placeholder" text which is inside a URL string , with another string that is stored inside a javascript variable. This variable is dynamically generated based on a user's choices, so I can't just hardcode the variable.
Here is my code thus far:
var result_photo = "http://quizsocial.com/yahoo/this.jpg";
var sRegExphoto = new RegExp(result_photo);
$('a.facer').each(function() {
this.attributes.onclick.nodeValue=this.attributes.onclick.nodeValue.replace('result_photo_placeholder', sRegExphoto);
});
You can also see my jsfiddle at: http://jsfiddle.net/Ywa7j/1/
This fiddle seems very close to me, but where I get stuck is that my javascript Regex bit that gets replaced into my string continues to have it's regex delimiters set around it. If I could get rid of those delimiters on my Regex object, I think I would be doing well. However, I simply cannot find a way to get rid of those delimiters.
Please help me figure this one out! Thanks a lot. If you have suggestions that will take me away from the way I'm attempting to do this now, I'm all ears, as well.
.replace('result_photo_placeholder', result_photo);