javascript - Getting JQuery html() with no character escaping -
javascript - Getting JQuery html() with no character escaping -
i have next problem:
var bodyhtml = 'test7\n' + '<a href="www.google.com">google</a>\n' + '<a href="www.google.com">google</a>\n' + '<a href="www.yahoo.com">yahoo</a>'; var $temphtml = $("<temphtml/>").html(bodyhtml); $temphtml.find("a").each(function (index, a) { var url = $(a).attr("href"); if (url === "www.google.com") { $(a).attr("href", "<%= track(1) %>"); } }); bodyhtml = $temphtml.html();
here jsbin this. problem have jquery .html()
function replaces <%
within href
tags <%
(escapes it). there way of preventing escaping since need string bodyhtml
remain unchanged?
i know how done on regex
, jquery
solution seems improve if done.
javascript jquery html
Comments
Post a Comment