See my code, I'm defining a function to call the function outside. But I want to simplify it as ("click",myFunction(e))
but e(event) is not transfering to the function. My point of view: how to
The code working properly: how to send event object to the fucntion proparly without adecribing anonymous function on addEvenListener
document.querySelector("#b1").addEventListener("click",function (e){myFunction(e)})
function myFunction(e) {
document.getElementsByTagName('h5')[0].innerHTML=e.target.tagName};
The code is not working:
document.querySelector("#b1").addEventListener("click",myFunction(e))
function myFunction(e) {
document.getElementsByTagName('h5')[0].innerHTML=e.target.tagName};