let x = document.createElement('p');
x.style.background = "aqua";
x.textContent = ' Click inside the box to Change background color ';
x.id = "para1";
console.log(x);
document.body.appendChild(x);
function changeBackgroundColor(e) {
e.target.style.background = "yellow";
}
document.getElementById("para1").addEventListener("click", changeBackgroundColor);
p {
border: solid green 2px;
margin-right: 65em;
margin-top: 24px;
}
Not able to see event listener in Microsoft edge tool (event listener has been added to code)
2
Answers
debugger
before the lines you want to test, not as your last thing in your code.The event is attached to an element. If you select this element then you can see its event handlers. You don’t have to pause the code for that.