Definition and usage of onclick event:
This event will be triggered when the object is clicked.
Browser support:
1.IE browser supports this event.
2. Firefox browser supports this event.
3. Opera browser supports this event.
4. Google Chrome supports this event.
5.Safria browser supports this event.
Example code:
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"/> <meta name="author" content="http://www.jb51.net/" /> <title>脚本之家</title> <style type="text/css"> div{ width:100px; height:100px; background-color:red; } </style> <script type="text/javascript"> window.onload=function(){ var mydiv=document.getElementById("mydiv"); mydiv.onclick=function(){ mydiv.style.backgroundColor="green"; } } </script> </head> <body> <div id="mydiv"></div> </body> </html>
The above content gives you a brief introduction to the javascript onclick event. I hope it will be helpful to you.