Deep understanding of jquery Custom Animation animate ()

Source: Internet
Author: User
Yesterday, a user suddenly asked me if the animate () method can be used to operate all css attributes? Yes, I told him yes. However, you need to be aware of this. Next, I will use this article to introduce the css style attribute Summary based on jqueryanimatecss. If you are interested in jqueryanimatecss, I will study it together. Yesterday, a user suddenly asked me about animate () can I operate on all css attributes? Yes, I told him yes. However, when using animate (), you must use the Camel flag to write all attribute names. For example, you must use paddingLeft instead of padding-left, use marginRight instead of margin-right.

Not all attributes in css can be dynamically changed using Jquery animation (animate function). The following summarizes some attributes of elements that JQ can operate on:

* BackgroundPosition * borderWidth * handle * borderSpacing * margin * marginBottom * marginLeft * marginRight * marginTop * outlineWidth * padding * handle * paddingLeft * paddingRight * paddingTop height * width * maxHeight * maxWidth * minHeight * maxWidth * font * fontSize (the css parameter specified in the animate function is not the same as the standard css attribute, for example, the css standard is: font-siz E. The same is true for many of the above cases) * bottom * left * right * top * letterSpacing * wordSpacing * lineHeight * textIndent * opacity

Remember these animation games ~~

You can also set non-css attributes in the animate () method of jquery.

Example:

$('body').animate({scrollTop:0}, 1500);$("body").animate({scrollTop:"-="+50},350);

There are several other small examples:

Disabled element:

$('button').attr('disabled', 'disabled'); $('button').removeAttr('disabled');

Traversal element set:

$ ("Input: text "). each (function (index) {alert (index); // The lower mark value of the loop, starting from 0 alert (this. value); // you can use this (Dom) to directly set the value of alert ($ (this ). attr ("type"); // attr () value must be used for Custom Attributes });

For more details about jquery Custom Animation animate (), please refer to PHP!

Related Article

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.