<html>
<head>
<script>
window.onload = function(){
var para = document.createElement("p");
para.innerHTML = "aaaa";
document.body.appendChild(para);
var bspan = document.createElement("span");
bspan.innerHTML = "bbbb";
para.appendChild(bspan);
bspan.onclick = function(){
alert("hi");
}
para.innerHTML += "cccc";
}
</script>
</head>
<body>
</body>
</html>
This is my code, I expect it to alert hi when I clicked on bbbb, but it obviously not functioning, why?