Created
June 28, 2015 23:50
-
-
Save anonymous/bb7c91d9e328dcac4689 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/hurilu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="div1"></div> | |
<script id="jsbin-javascript"> | |
var parentDiv = document.getElementById("div1"); | |
var newParagraph = document.createElement("p"); | |
var t = document.createTextNode("Hello World"); | |
newParagraph.appendChild(t); | |
parentDiv.appendChild(newParagraph); | |
//end 1st paragraph insertion | |
var anotherNewParagraph = document.createElement("p"); | |
var t2 = document.createTextNode("Goodbye World!"); | |
anotherNewParagraph.appendChild(t2); | |
paragraph1 = parentDiv.firstChild; | |
parentDiv.insertBefore(anotherNewParagraph, paragraph1); | |
//end 2nd paragraph insertion before 1st paragraph | |
var yetAnotherNewParagraph = document.createElement("p"); | |
var t3 = document.createTextNode("I'm Back"); | |
yetAnotherNewParagraph.appendChild(t3); | |
var target = parentDiv.childNodes[1]; | |
parentDiv.insertBefore(yetAnotherNewParagraph,target.nextSibling); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var parentDiv = document.getElementById("div1"); | |
var newParagraph = document.createElement("p"); | |
var t = document.createTextNode("Hello World"); | |
newParagraph.appendChild(t); | |
parentDiv.appendChild(newParagraph); | |
//end 1st paragraph insertion | |
var anotherNewParagraph = document.createElement("p"); | |
var t2 = document.createTextNode("Goodbye World!"); | |
anotherNewParagraph.appendChild(t2); | |
paragraph1 = parentDiv.firstChild; | |
parentDiv.insertBefore(anotherNewParagraph, paragraph1); | |
//end 2nd paragraph insertion before 1st paragraph | |
var yetAnotherNewParagraph = document.createElement("p"); | |
var t3 = document.createTextNode("I'm Back"); | |
yetAnotherNewParagraph.appendChild(t3); | |
var target = parentDiv.childNodes[1]; | |
parentDiv.insertBefore(yetAnotherNewParagraph,target.nextSibling);</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parentDiv = document.getElementById("div1"); | |
var newParagraph = document.createElement("p"); | |
var t = document.createTextNode("Hello World"); | |
newParagraph.appendChild(t); | |
parentDiv.appendChild(newParagraph); | |
//end 1st paragraph insertion | |
var anotherNewParagraph = document.createElement("p"); | |
var t2 = document.createTextNode("Goodbye World!"); | |
anotherNewParagraph.appendChild(t2); | |
paragraph1 = parentDiv.firstChild; | |
parentDiv.insertBefore(anotherNewParagraph, paragraph1); | |
//end 2nd paragraph insertion before 1st paragraph | |
var yetAnotherNewParagraph = document.createElement("p"); | |
var t3 = document.createTextNode("I'm Back"); | |
yetAnotherNewParagraph.appendChild(t3); | |
var target = parentDiv.childNodes[1]; | |
parentDiv.insertBefore(yetAnotherNewParagraph,target.nextSibling); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment