This article mainly introduces the application of jquery Toggleclass, the need for friends can refer to the following
1, first to the jquery website to download JS Library, Web site for http://jquery.com/ 2, the establishment of a jquery sample project. 3, put the JS library into the jquery sample project. 4, write an HTML page code as follows: <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > <html > <head> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <meta http-equiv= Author" content= "Kong.yee"/> <meta http-equiv= " Corporation "content=" Guangzhou Kuang Xing Software Technology Co., Ltd. "/> <meta http-equiv=" Contact "content=" 791663094 or kong.yee@ Foxmail.com "/> <script type= text/javascript" language= "JavaScript" src= "Js/jquery-1.10.2.js" ></ script> <title>insert title here</title> <style type= "text/css" > .bg{ /* Background color */ background: #f00; /* Font color */ color: #fff; width:80px; } UL, Li { /* Clear UL and Li on the default dot */ list-style:none; } UL { /* Clear Sub Menu indentEnter value */ PADDING:0;/*IE8,IE9, Firefox can be ie7,ie6,ie5.5 No, */ margin:0;/* are all available */ } </style> <script type= "Text/javascript" > $ (function () { //setcolor is the method of mouse movement $ ("Li"). MouseOver ( SetColor). Mouseout (setcolor); function setcolor () { //Delete (add) a class $ (this) if present (not present). Toggleclass ("BG"); } }); </script> </head> <body> <div id= " Div "> <ul> <li> Landscape menu 1</li> <li> Landscape menu 2</li> <li> Landscape Menu 3 </li> <li> Landscape Menu 4</li> <li> Landscape menu 5</li> <li> Landscape Menu 6</li> </ul> </div> </body> </html>