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!