Instead of event.toElement you should use this:
event.target
More Related Contents:
- How to make JavaScript execute after page load?
- onKeyPress Vs. onKeyUp and onKeyDown
- Browser detection versus feature detection
- Event when window.location.href changes
- Why is the DOMSubtreeModified event deprecated in DOM level 3?
- How do I do OuterHTML in firefox?
- Manipulating innerHTML removes the event handler of a child element? [duplicate]
- Adding an onclick event to a table row
- How to add/remove a class in JavaScript?
- Pass mouse events through absolutely-positioned element
- Unable to understand useCapture parameter in addEventListener
- Using this inside an event handler
- Enter key press behaves like a Tab in Javascript
- Change ‘s option and trigger events with JavaScript
- Get the string representation of a DOM node
- Native JS equivalent to jQuery delegation
- Are event handlers in JavaScript called in order?
- HTML DOM: Which events do not bubble?
- Do I need to remove event listeners before removing elements?
- link element onload
- Wait for iframe to load in JavaScript
- cloning javascript event object
- Is there any way of passing additional data via custom events?
- window.focus() not working in Google Chrome
- How can I know whether refresh button or browser back button is clicked in Firefox? [duplicate]
- How browser executes Javascript and renders asynchronously
- Use JavaScript to intercept all document link clicks
- In web browsers, what’s the difference between onblur and onfocusout?
- Replacement for deprecated `keypress` DOM event
- Manually dispatchEvent DOMContentLoaded