Created
March 23, 2014 15:26
-
-
Save kumarldh/9724624 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<title>Hydra - Delete one button & produce two more!</title> | |
<meta charset="UTF-8"> | |
</head> | |
<body id="hydrabody"> | |
<button class="hydrahead">Hydra Head</button> | |
</body> | |
<script> | |
document.addEventListener('click', function(e){ | |
if(e.target.className !=='hydrahead'){ | |
return; | |
} | |
var bd = document.getElementById('hydrabody'); | |
var lefthead = document.createElement('button'); | |
var righthead = document.createElement('button'); | |
lefthead.setAttribute('class','hydrahead'); | |
lefthead.innerHTML = 'Left Hydra Head'; | |
righthead.setAttribute('class','hydrahead'); | |
righthead.innerHTML = 'Right Hydra Head'; | |
bd.removeChild(e.target); | |
bd.appendChild(lefthead); | |
bd.appendChild(righthead); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment