Unwrap Selected Element Javascript Or Jquery
This is my html. Lorem Ipsum is simply dummy I'm selecting with with $('#curr
Solution 1:
You can chain contents() into unwrap():
$("#current").contents().unwrap();
contents()
will return all the children of #current
, including text nodes, and unwrap()
can be applied to text nodes.
Solution 2:
var$current = $('#current');
$current.replaceWith($current.text());
Fiddle with the two current answers - pun?
Solution 3:
Just hit this same question. I think this might be marginally better...same effect but I think jQuery has to do less magic to make this work.
$("#current").replaceWith($("#current").contents());
Post a Comment for "Unwrap Selected Element Javascript Or Jquery"