Javascript examples for DOM:Event
Use this to reference current element during event handling
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w .j a va 2s .c o m*/ document.getElementById('red').onclick = function(){ this.style.color = "red"; } } </script> </head> <body> <ul> <li> <a id="red" href="#">List Item with Function</a> </li> <li> <a href="#">List Item without Function</a> </li> </ul> </body> </html>