A summary of CSS style attributes based on jquery animate operations _jquery

Source: Internet
Author: User

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 ()) 
;
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.