Replacing an element with .replaceWith()

.replaceWith()


Description: Replace an element with either an element or content.


Example:

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

Preview:

This paragraph is my new container

  • Usage

    • How to use:

      Replace an element with either an element or content using our .replaceWith() method

    • USAGE:

      bitsyCode('elementToReplace').replaceWith("element/content");
  • 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