[Jquery tutorial] jquery CSS Function

Source: Internet
Author: User
Jquery CSS operations

Jquery has three important functions for CSS operations:

  • ((Selector).css (name, value)
  • Detail (selector).css ({properties })
  • ((Selector).css (name)
CSS operation instance

The function CSS (name, value) sets the value for the given CSS attribute of all matching elements:

Instance

((Selector).css (name, value)
$ ("P" ).css ("background-color", "Red ");

Function CSS ({properties}) simultaneously sets values for a series of CSS attributes of all matching elements:

Instance

Detail (selector).css ({properties })
$ ("P" ).css ({"background-color": "red", "font-size": "200% "});

The function CSS (name) returns the value of the specified CSS attribute:

Instance

((Selector).css (name)
Background (this).css ("background-color ");

Jquery size operation

Jquery has two important functions for dimensional operations:

  • $ (Selector). Height (value)
  • $ (Selector). Width (value)
Jquery CSS operation functions

The methods listed below set or return CSS-related attributes of elements.

CSS attributes Description
CSS () Set or return the style attribute of the matching element.
Height () Sets or returns the height of the matching element.
Offset () Returns the position of the First Matching Element relative to the document.
Offsetparent () Returns the nearest ancestor element.
Position () Returns the position of the First Matching Element relative to the parent element.
Scrollleft () Sets or returns the offset of the matching element relative to the top of the scroll bar.
Scrolltop () Sets or returns the offset of the matching element to the left of the scroll bar.
Width () Set or return the width of the matching element.

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.