JQuery uses the empty () method to delete elements and all their child elements
This article mainly introduces how jQuery uses the empty () method to delete elements and all their child elements. It involves jQuery's skill in operating elements and has some reference value. For more information, see
This example describes how jQuery uses the empty () method to delete elements and all their child elements. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<! DOCTYPE html> <Html> <Head> <Script src = "js/jquery. min. js"> </Script> <Script> $ (Document). ready (function (){ $ ("Button"). click (function (){ $ ("# Div1"). empty (); }); }); </Script> </Head> <Body> <Div id = "div1" style = "height: 100px; width: 300px; border: 1px solid black; background-color: yellow;"> This is some text in the div. <P> This is a paragraph in the div. </p> <P> This is another paragraph in the div. </p> </Div> <Br> <Button> Empty the div element </button> </Body> </Html> |
I hope this article will help you with jQuery programming.