pstein Posted December 22, 2023 Share Posted December 22, 2023 Assume I have a html code similar to <div class="foobar" ....> <p> <div> first stuff</div> <div class="sec"> second stuff </div> ..... </div> 1.) How can I delete the first <div> element INSIDE the <div> parent element with class="foobar"? 2.) How can I delete the first <div> brother element BEFORE the <div> element with class="sec"? If possible suggest a jQuery code. Otherwise JavaScript is acceptable too. Thank you Peter Link to comment Share on other sites More sharing options...
dsonesuk Posted January 6 Share Posted January 6 $(".foobar > div").eq(0).remove(); $(".sec").prev().remove(); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now