Remove childnodes from parent using .empty()

.empty()


Description: Remove child nodes from parent element.


Example:

<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>empty demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
      
      <div class="container">
         <p>This is a paragraph.</p>
         <span>and I am a span.</span>
      </div>
      
      <script>
         
         bitsyCode.ready(function(){
            
            bitsyCode('.container').empty();
            
         })
         
      </script>
     
    </body>
    </html>

Preview:

<div class="container"></div>

  • Usage

    • How to use:

      Using the .empty() method will remove all child nodes from parent element.

    • USAGE:

      bitsyCode('element').empty();
  • Options

    • What options are there:

      There are no options for this method.

  • Returns

    • Returns: No return type

      This method does not need to return any type.

Share