'why not get expected result by the addEventListener method in javascript
output is "PointerEvent {isTrusted: true, pointerId: 1, width: 1, height: 1, pressure: 0, …}",it is not expected
the expected result is "li".
please help,thanks.
<script type="text/javascript">
function elementCheckChange(eve)
{
console.log(eve);
}
function init()
{
var root=document.getElementById("container");
console.log(root)
for(var i =0;i<3;i++)
{
var sub_ele=document.createElement("li");
sub_ele.innerHTML=i;
sub_ele.addEventListener("click",elementCheckChange.bind(this));
root.appendChild(sub_ele);
}
}
</script>
<body onload="init()">
<ul id="container">
</ul>
</body>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|