Sample Code of jquery animate image mode sliding

Source: Internet
Author: User

Each attribute in this object represents a changeable style attribute (such as "height", "top", or "opacity "). Note: All specified attributes must be in the form of camels. For example, marginLeft must be used to replace margin-left. The value of each attribute indicates how many style attributes are ended when the animation ends. If it is a value, the style property will gradually change from the current value to the specified value. If a string value such as "hide", "show", or "toggle" is used, the default animation format is called for this attribute.

The function declaration is as follows:Copy codeThe Code is as follows: animate (params [, duration [, easing [, callback])

In jQuery, you can use em and % units. In addition, you can specify "+ =" or "-=" before the attribute value to make the element do relative motion.

The following shows an example of Sliding between the image list and the left and right sides. The main code is as follows:Copy codeThe Code is as follows: <script type = "text/javascript">
$ (Function (){
$ Li1 = $ (". apply_nav. apply_array ");
$ Window1 = $ (". apply. apply_w ");
$ Left1 = $ (". apply. img_l ");
$ Right1 = $ (". apply. img_r ");

$Window1.css ("width", $ li1.length * 166 );

Var lc1 = 0;
Var rc1 = $ li1.length-5;
$ Left1.click (function (){
If (lc1 <1 ){
Alert ("already the first image ");
Return;
}
Lc1 --;
Rc1 ++;
$ Window1.animate ({left: '+ = 166px'}, 1000 );
});

$ Right1.click (function (){
If (rc1 <1 ){
Alert ("the last image ");
Return;
}
Lc1 ++;
Rc1 --;
$ Window1.animate ({left: '-= 166px'}, 1000 );
});
})
</Script>

Running result:

Online Demo: http://demo.jb51.net/js/2011/jqueryanimate/index.html
Download source code: Click to download

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.