JQuery Toggleclass Application Example

Source: Internet
Author: User
Tags html page

  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>   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.