Yesterday, a netizen asked me animate () method can be used to manipulate all CSS properties? Yes, I told him it was OK. However, there is a need to pay attention to the need to be clear: when using animate (), you must use the Camel notation to write all the property names, for example, you must use Paddingleft instead of padding-left, use MarginRight instead Margin-right, wait.
Not all attributes in CSS can be dynamically changed with the jquery animation (animate function), which summarizes some of the properties that JQ can manipulate elements:
* backgroundposition *
borderwidth * borderbottomwidth * borderleftwidth *
borderrightwidth
* borderTopWidth *
borderspacing * margin * marginbottom *
marginleft
* marginright * MarginTop *
outlinewidth * padding * paddingbottom *
paddingleft
* paddingright * Paddingtop
* Height *
width *
maxheight
* maxwidth *
minheight * maxwidth *
Font
* fontsize (CSS parameters in the Animate function are specified and differ from the standard CSS attributes, such as the CSS Standard: Font-size.) The same is true of many of these cases)
* Bottom * left * right * top *
letterspacing *
wordspacing
* Lineheight
* textindent
* Opacity
Remember these can play animation Oh ~ ~
The animate () method of jquery can also set non-CSS properties
The title, for example:
$ (' body '). Animate ({scrolltop:0}, 1500);
$ ("body"). Animate ({scrolltop: "=" +50},350);
There are a few other small examples:
To disable an element:
$ (' button '). attr (' disabled ', ' disabled ');
$ (' button '). Removeattr (' disabled ');
To traverse the collection of elements:
$ ("Input:text"). each (function (index) {
alert (index),//loop subscript value, starting at 0
alert (this.value);//self-with attribute can be used with this (DOM) Direct Value
alert ($ (this). attr ("type"));//custom attribute requires a value of attr ())
;