I've been working at this for the last hour, but I am still unable to get the expected output... All I want is to create an HTML element using the onclick event. I was able to create the element on load, but find myself unable to with the event. Please lead me in the right direction. Here's my HTML page:
<html>
<body>
<div id="d1">
<p id="p1">Paragraph.</p>
</div>
<div id="d2">
<label onclick="open()">Inbox</label>
</div>
<script>
function open(){
alert("Start");
var para=document.createElement("p");
var node=document.createTextNode("Text");
para.appendChild(node);
para.style.color="red";
var element=document.getElementById("d2");
element.appendChild(para);
}
</script>
</body>
</html>