Javascript examples for DOM HTML Element:Image
Global and local variable on the event handler function
<html lang="en"> <head></head> <body translate="no"> <meta charset="utf-8"> <img src="https://placehold.it/100x100"> <script> window.onload = function(event){ var img = document.getElementsByTagName("img"),five; img[0].onmousedown = function(event) { console.log(five); five = 5;/* ww w . j a v a 2 s .co m*/ }; }; </script> </body> </html>