JQuery implements menu-based mouse sliding animation.
This article describes how jQuery achieves menu-induced mouse sliding animation. Share it with you for your reference. The specific analysis is as follows:
This code test environment may not be supported by IE9, GG, and FF browsers.
This JS mouse slide effect uses jQuery to implement simple animation, and it is also surprising that jquery has a better writing method and can be written repeatedly, after the stop method is added before the animate method, the mouse can be removed without moving any more.
Copy codeThe Code is as follows: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> very good jQuery mouse sliding effect </title>
<Script src = "js/jquery. min. js" type = "text/javascript"> </script>
<Style>
Body {font-size: 12px; font-family: Tahoma, Arial, Verdana; color: # fff; background: #000; width: 100%; height: 100% ;}
Body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td, I {padding: 0; margin: 0}
Fieldset, img {border: 0}
. Clear {clear: both ;}
Address, caption, cite, code, dfn, em, th, var {font-weight: normal; font-style: normal}
Ol, ul {list-style: none}
Caption, th {text-align: left}
H1, h2, h3, h4, h5, h6 {font-size: 100%}
Abbr, acronym, img {border: 0}
Button, input, select, textarea {font-size: 100% ;}
Input, button, textarea, select, optgroup, option {font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit ;}
Table {border-collapse: collapse; border-spacing: 0 ;}
A {text-decoration: none ;}
A: hover {text-decoration: underline ;}
. Clearfix: after {visibility: hidden; display: block; font-size: 0; content: "."; clear: both ;}
. All ul {width: 100%; text-align: center ;}
. All ul li {width: 100%; height: 40px; line-height: 40px; border-bottom: 1px dashed #990066; cursor: pointer ;}
</Style>
</Head>
<Body>
<Div class = "all">
<Ul>
<Li> Item 1 </li>
<Li> Item 2 </li>
<Li> Item 3 </li>
</Ul>
</Div>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ('. All ul li'). mouseover (function (){
$ (This). animate ({"height": "70px", "line-height": "70px"}, 100)
}). Mouseleave (function (){
$ (This). stop (). animate ({"height": "40px", "line-height": "40px"}, 100)
});
})
</Script>
</Body>
</Html>
I hope this article will help you with jQuery programming.