Skip to content

Instantly share code, notes, and snippets.

@rodvan
Created January 28, 2015 23:14
Show Gist options
  • Save rodvan/79a5ed7a3cd6d5e4bae4 to your computer and use it in GitHub Desktop.
Save rodvan/79a5ed7a3cd6d5e4bae4 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<p>This is the number 1</p>
<p>This is the number 2</p>
<p>This is the number 3</p>
<p>This is number 4</p>
<div id="foo">
</div>
<div>
<p>And this is the number 5</p>
</div>
<input type="text" id="user"></input>
<input type="text" id="message"></input>
<button onclick="add()">Add</button>
<script id="jsbin-javascript">
var add = function() {
var el = document.createElement("p"),
user = document.getElementById("user"),
message = document.getElementById("message"),
content = document.createTextNode("User: " + user + " <br>Message: " +message),
divFoo = document.getElementById("foo");
el.appendChild(content);
el.id = "bar";
divFoo.appendChild(el);
};
</script>
<script id="jsbin-source-javascript" type="text/javascript">var add = function() {
var el = document.createElement("p"),
user = document.getElementById("user"),
message = document.getElementById("message"),
content = document.createTextNode("User: " + user + " <br>Message: " +message),
divFoo = document.getElementById("foo");
el.appendChild(content);
el.id = "bar";
divFoo.appendChild(el);
};
</script></body>
</html>
var add = function() {
var el = document.createElement("p"),
user = document.getElementById("user"),
message = document.getElementById("message"),
content = document.createTextNode("User: " + user + " <br>Message: " +message),
divFoo = document.getElementById("foo");
el.appendChild(content);
el.id = "bar";
divFoo.appendChild(el);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment