If I want a function to be executed, I prefer doing inline js:
<p id="element" onclick="doSomething();">Click me</p>
because it is easier to debug.
However, I hear people saying not to use inline js, and do:
document.getElementById('element').onclick = doSomething;
Why is the js event listener recommended?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…