You need to pass the string to jQuery: $(html).find("<td>UP</td>").replaceWith("<td><img...></td>");
You could also do a simple text replace: html.replace('UP', '<img src="...>') On May 25, 9:47 pm, DanN <danny_no...@yahoo.co.uk> wrote: > I have a variable called html thats created on document load with > jquery and XML, I want to search that variable for a string, and > replace it with another. > > ie > > html = '<td>UP</td><td>DOWN</td><td>UP</td><td>UP</td><td>DOWN</ > td><td>UP</td>' > > I then basically want to do: > > html.find("<td>UP</td>").replaceWith("<td><img...></td>") > > It does not need to be recursive, but can be. > > If recursive, will get used before the var is dumped to a div. If not > will get used in the loop and change the html var as created and wont > matter. Either way, as long as it works. > > I tried several things, but kept getting this error: > > uncaught exception: Syntax error, unrecognized expression: > > > Please help!