Javascript examples for DOM Event:onclick
Assign click event handler to all element
<html> <head></head> <body> <!--<input id="boton" type="button" value="virtual cl">--> <p id="boton">pBoton</p> <script> var clickHandler = function(){ console.log('clicked!'); }; var elements = document.getElementsByTagName('p'); for(var i = 0; i<elements.length; i++){ elements[i].onclick = clickHandler; } </script> </body>//from ww w .j av a 2 s . c o m </html>