jquery - Replace the text using javascript -
I am using code below to change the text within the h1 tag, but it is not being affected I want to change "sample" to "new sample" am I doing wrong?
& lt; Div class = "content" & gt; & Lt; H2 & gt; Sample & lt; / H2 & gt; & Lt; / Div & gt; Var t = jQuery ('. Content'); T. Hair ("H2") Each (function () {var content = jQuery (this) .contents (); jQuery (this) .replaceWith (new sample);});
If you want to change some of the contents, try it out:
jQuery ('. Content H2'). Replace each (function (i, v) {$ v = $ (v); $ v.html ($ v.html (). ('Sample', 'new sample'));};
Comments
Post a Comment