I am looking at https://www.w3schools.com/html/html5_draganddrop.asp and I'm trying to understand why ondragstart = "drag(event)" works but not "drag(ev)"?
`function drag(ev) { ev.dataTransfer.setData("text", ev.target.id); }
`
I am looking at https://www.w3schools.com/html/html5_draganddrop.asp and I'm trying to understand why ondragstart = "drag(event)" works but not "drag(ev)"?
`function drag(ev) { ev.dataTransfer.setData("text", ev.target.id); }
`
The event attributes (e.g. ondrop="drop(event)") are passing the window event property to the function defined in the attribute. You can replace event with window.event on the W3Schools Tryit page and it still works, but if you replace event with ev, it won’t work as there is no windows.ev variable defined. ev is the variable in the event handlers given to the event that's passed to the event handlers.