An area on a Web page, when the mouse moved to change the style, the mouse out of the automatic recovery style, can be a picture of the border, can also be a paragraph of text color, master the principle, seemingly can do more rich and vivid interactive effect of the Web page, here is the use of JS control hover tag in the DIV generated action, is also a good example of learning.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> mouse move out change CSS style </title> <style> body{color: #fff; font:12px/1.5 Tahoma;} div1{width:150px;height:150px;margin:0 auto;padding:10px;background:black;border:10px solid #000; cursor:crosshair ;} #div1. Hover{color:red;background: #f0f0f0; border:10px solid red;} </style> <script> window.onload = function () {var odiv = document.getElementById ("Div1"); Odiv.onmouseover = function () {odiv.classname = "hover"}; Odiv.onmouseout = function () {odiv.classname = ' "}}; </script> </pead> <body> <div id= "Div1" > Mouse moveChange the style and move the mouse out of the recovery. </div> </body> </ptml>