Javascript basic tutorial event small example
Small example of Javascript event:
Change the color of the div by clicking the button
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>事件</title> <style type="text/css"> div{width:150px;height:150px;border:1px solid #f60;}</style> </head> <body> <div id="dv"></div><br> <input type="button" value="点击" onclick="bt()"> <script type="text/javascript"> function bt(){ var div=document.getElementById("dv"); div.style.backgroundColor="red"; } </script> </body> </html>