The JQuery Remove () method deletes the selected element and its child elements. Examples are as follows:
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <Scriptsrc= "/jquery/jquery-1.11.1.min.js"></Script>5 <Script>6 $ (document). Ready (function(){7 $("Button"). Click (function(){8 $("#div1"). Remove ();9 });Ten }); One </Script> A </Head> - - <Body> the - <DivID= "Div1"style= "height:100px;width:300px;border:1px solid black;background-color:yellow;"> - This is some text in the Div. - <P>This was a paragraph in the Div.</P> + <P>This is another paragraph in the Div.</P> - </Div> + A <BR> at <Button>Delete div element</Button> - - </Body> - </HTML>
Click the button before the following:
After clicking the button:
Remove () Removes the contents of the entire div-selected ID section.
The JQuery Empty () method deletes the child elements of the selected element.
Replace the Remove in the above code with empty () and click the button:
Empty () does not clear the selected part but clears the sub-section of the selected part.
The difference between jquery remove () and jquery Empty ()