JavaScript string replace is not working

javascript

Solution

try

liHTML = liHTML.replace("IMG_TITLE", imgTitle);

Problem

Possible Duplicate: javascript replace function not working Here is my JS code: ``` var imgTitle = "fizz"; var imgTitle2 = "fizz"; var imgInfo = "buzz"; var imgSrc = "foo"; var liHTML = "<li class='imgThumbLi ui-draggable' title='IMG_TITLE'><img class='image' src='IMG_SRC' title='IMG_TITLE'/><div class='imageInfo'><p class='detailTitle'>IMG_INFO</p></div></li>"; // Search and replace all dummy values. liHTML.replace("IMG_TITLE", imgTitle); liHTML.replace("IMG_TITLE2", imgTitle2); liHTML.replace("IMG_SRC", imgSrc); liHTML.replace("IMG_INFO", imgInfo); alert(liHTML); ``` Getting this for print out: ``` <li class='imgThumbLi ui-draggable' title='IMG_TITLE'><img class='image' src='IMG_SRC' title='IMG_TITLE'/><div class='imageInfo'><p class='detailTitle'>IMG_INFO</p></div></li> ``` (Same as before the string replace calls). In Firebug I'm getting an error stating: c.replace is not a function Get this error anytime the code snippet above executes. Why isn't this string replace working?!?! Thanks in advance!

Original source

Related problems