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 &lt% (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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -