Need to remove all the code from the start tag to the next
I've tried this
$('#page1').remove();
But that only removes what's between the tag.
And I don't know what else could be between the page1 and page2 tags as the code is dynamically added based on the types of form elements on the page
<div id='page1' name='page1'>
...
</div>
<div id='another element' />
<div id=yet 'another element' />
...
<!-- Need to remove from page1 to here -->
<div id='page2' name='page2'>
...
</div>
Assuming you want to remove page1
and everything until page2
you can do this:
$("#page1").nextUntil("#page2").andSelf().remove();
Example on jsfiddle
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