javascript - How to remove element from HTML string? -


this doesn't seem working, uncaught type error on .remove() line:

js:

var str = $("a").html(); var $html = $.parsehtml(str); $("i",$html).remove();    $("div").html($html); 

html:

<a href="#">hello <i>bob</i></a> <div></div> 

how work?

you can clone a, change html code of clone , put clone inside div.

fiddle.

$(document).ready(function() {     var clone = $("a").clone();     clone.find("i").remove();     $("div").html(clone); });     

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -