Luv2Muff
asked on
Remove a tag but leave the text
This is my code:
<div id="test">
<p>My Text</p>
<p>My Text</p>
</div>
I need jQuery that will remove all the p tags from#test and just leave:
<div id="test">
My Text
My Text
</div>
Thanks in advance.
<div id="test">
<p>My Text</p>
<p>My Text</p>
</div>
I need jQuery that will remove all the p tags from#test and just leave:
<div id="test">
My Text
My Text
</div>
Thanks in advance.
ASKER
Hi, That removes all the text inside the tag
save the text into a variable then apply the code.
Get a array to record it and remove the tags.
Good luck!
Get a array to record it and remove the tags.
Good luck!
ASKER
Any help with the code for that would be much appreciated :-)
Try :
$("p", "#test").each(function() {
$(this).replaceWith( $(this).html() )
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works a treat thanks you!!
$("#teste p").remove();
or
$("#teste").children("p").
$(this).remove();
});
Open in new window