Hello i need to remove a form tag but non the content:
<form id="form">
<div> not remove this only the form tag</div>
</form>
Remove Elements/Content. To remove elements and content, there are mainly two jQuery methods: remove() - Removes the selected element (and its child elements) empty() - Removes the child elements from the selected element.
Sometime you might require to remove the wrapper or parent element, a typical example is removing the anchor tag around the text. With jQuery unwrap () method you can easily remove the wrapper element and keep the inner HTML or text content intact.
Sometimes you may need to remove the parent element, a typical example is removing the anchor tag around the text. With jQuery’s unwrap () method, you can easily remove the parent element and keep the HTML content or internal text intact. <p>Lorem ipsum dolor sit amet, consectetur adipiscing <a href="#" class="lien">this is a link</a>.
You can also strip/remove HTML tags from any variable as well as text () is jQuery function, so the variable needs to be converted into a jQuery object so that text () can be used. Feel free to contact me for any help related to jQuery, I will gladly help you.
$form = $('#form');
$form.replaceWith($form.html());
Should do what you need.
add an id or class to your div
e.g.
<form id="form">
<div class="wrapper"> not remove this only the form tag</div></form>
Then
$(".wrapper").unwrap();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With