Remove the child elements of <div>. - Javascript jQuery

Javascript examples for jQuery:Tag Edit

Description

Remove the child elements of <div>.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("div").empty();
});// w  w w  .  j  av  a2  s  .c  o m
</script>
</head>
<body>

<div 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>

</body>
</html>

Related Tutorials