Skip to content

Instantly share code, notes, and snippets.

@nikkaroraa
Last active November 13, 2017 20:09
Show Gist options
  • Save nikkaroraa/86550ffafaf5b29bd6f7e954d6552e95 to your computer and use it in GitHub Desktop.
Save nikkaroraa/86550ffafaf5b29bd6f7e954d6552e95 to your computer and use it in GitHub Desktop.
Adding to DOM
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<div class="container">
</div>
</body>
<script>
//creating a new element node
var newElementNode = document.createElement('p');
//appending the new element node to existing div
var div = document.querySelector('.container');
div.appendChild(newElementNode);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment