DEV Community

Cover image for Javascript methods
bagavath ravichandran
bagavath ravichandran

Posted on

2

Javascript methods

Here are the methods i learned today,

1.appendchild()
This method adds a node to the end of the list of children of
a specified parent node

   E.g: 
       <script>             
        const document.createElement("h1")
        element.innertext="Hello"
        document.body.appendchild(element)
       </script>
  In here the appendchild will create a element with h1 tag 
  with the output as "Hello".

  In writing in script we can  directly create a element in the
  body from javascript.
Enter fullscreen mode Exit fullscreen mode

2.append()

    This method inserts a set of Node objects or strings after 
    the last child of the document.
Enter fullscreen mode Exit fullscreen mode

3.Difference b/w appendchild() and append()

 append() is used to add HTML content or an element to the end 
 of an existing element while appendChild() is used to add a 
 new node element as a child to an existing node.
Enter fullscreen mode Exit fullscreen mode

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

If you found this post helpful, please leave a ❤️ or a friendly comment below!

Okay