JQuery / Regex: Remove Div With Nested Divs From TD
I have a TD that always contains a div and some text outside the div. The div has four nested divs that always follow the below structure. The only thing I am interested in is th
Solution 1:
Ten kittens in China just died, and four unicorns where brutally sterilized!
Why would you do such a thing with a regex ?
To remove every DOM node and just keep textNodes, filter on nodeType and remove the rest.
$('#myTD').contents().filter(function() {
return this.nodeType != 3;
}).remove();
Solution 2:
Have you tried:
$("#myTD>div").remove()
Post a Comment for "JQuery / Regex: Remove Div With Nested Divs From TD"