Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created December 26, 2013 05:34
Show Gist options
  • Select an option

  • Save chikoski/8130152 to your computer and use it in GitHub Desktop.

Select an option

Save chikoski/8130152 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<input type="button" value="くりっく" id="btn">
<div id="output">
</div>
</body>
</html>
window.addEventListener("load", function(event){
var observer = new MutationObserver(function(record, observer){
console.log("mutated");
});
var output = document.getElementById("output");
observer.observe(output, { childList: true });
var btn = document.getElementById("btn");
var counter = 0;
btn.addEventListener("click", function(event){
counter = counter + 1;
var p = document.createElement("p");
p.textContent = counter;
output.appendChild(p);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment