javascript - How to modify html string using jQuery -
i try use jquery modify html template.
for example:
var d = '<div class="a"><div class="b"></div><div class="c"></div></div>';  var html = $(d).find(".b").html("bbbbb");  console.log(d);   // want new html    in above, want
'<div class="a"><div class="b">bbbbb</div><div class="c"></div></div>'
how can implement case? please suggest.
so here code:
var d = '<div class="a"><div class="b"></div><div class="c"></div></div>';  var html = $(d).find(".b").html("bbbbb").end()[0].outerhtml;  console.log(html);   note key use .end(), pop off context of <div class="b"> created .find() operation , return $(d), allows full html using .outerhtml on raw dom node.
Comments
Post a Comment