Thursday, 22 August 2013

why this simple snippet of javascript code dosen't work

why this simple snippet of javascript code dosen't work

Where am I doing wrong? Why this snippet of javascript code dosen't work?
This must be easy, but I just don't know why, I'm really a newbie at this
<!DOCTYPE html>
<html>
<body>
<p id="demo">Click the button to make a BUTTON element.</p>
<button onclick="myFunction()">Try it</button>
<script type="text/javascript">
function myFunction()
{
var bodyel = document.getElementById("body");
var block = document.createElement("div");
block.innerHTML = "whatever";
bodyel.appendChild(block);
};
</script>
</body>
</html>

No comments:

Post a Comment