Wednesday, 18 September 2013

How to convert a string to DOM and selecting within it

How to convert a string to DOM and selecting within it

I have a string containing HTML.
I need
part one: convert the string to DOM element and using jquery to selecting
all images
part two: update all image src adding "xxxx/" before the current src value
Any idea how to do it?
var resp = '<div><img src="smiley.gif"></div><div><img
src="smiley.gif"></div><div><img src="smiley.gif"></div>';
var dom = $(resp).html();
the result rendered as html should be:
<div><img src="xxxx/smiley.gif"></div><div><img
src="xxxx/smiley.gif"></div><div><img src="xxxx/smiley.gif"></div>;

No comments:

Post a Comment