This article describes the method of JS to sense the mouse changes in the background image. Share it for your reference. The specific analysis is as follows:
After clicking the mouse, the background image changes. Clicking on the front of another menu item will automatically restore the background. In fact, if you simply use CSS, you cannot do this. We also need to use JS to judge the mouse status. The code is as follows:
<style type="text/css"> .dh a{background:#FFFCC;width:50px;height:30px;display:block; text-align:center;color:#000000;} .dh a:hover{background:#FF9900;} </style> </head> <body> <div> <div><a href="#">Navigation1</a></div> <div><a href="#">Navigation2</a></div> <div><a href="#">Navigation3</a></div> <div><a href="#">Navigation4</a></div> <div><a href="#">Navigation4</a></div> <div><a href="#">Navigation1</a></div> <div><a href="#">Navigation2</a></div> <div><a href="#">Navigation3</a></div> <div><a href="#">Navigation4</a></div> <div><a href="#">Navigation 5</a></div> </div> <script type="text/javascript"> $(function(){ $(".dh a").click(function(){ $(".dh a").removeAttr("style"); $(this).attr("style","background:#CCFF99;"); }) }) </script>I hope this article will be helpful to everyone's JavaScript programming.