CSS in jquery

Source: Internet
Author: User

1.css

1.1 CSS (name)

$ (function () {
Alert ($ ("P"). CSS ("color"));

})//rgb (255,0,0)

1.2 css (JSON) where the value of the JSON array is function (Index,value) {return parsefloat (value) *1.2}, where the JSON object member is the property

$("div").click(function() {

    $(this).css({      width: function(index, value) {        return parseFloat(value) * 1.2;      },       height: function(index, value) {        return parseFloat(value) * 1.2;      }    });  });

1.3 css (Name,value)

Where name value is the object property and value

("P"). CSS ("Color", "red");

1.4 CSS (JSON) writes the individual values of the Set object as JSON to set the object's properties

$("p").css({ "margin-left": "10px", "background-color": "blue" });

2 location

2.1 Offset ()

Gets the relative offset of the matching element at the current viewport.

var offset= ("div"). offset ();

var offsetleft=offset.left;

var offsettop=offset.top;

2.2 Offset (coordinate)

Sets the coordinates of the matching element relative to the document object.

("div"). Offset ({left:20px,top:20px});

2.3 Position () usage with offset () (Supplemental: var p = $("p:first"); 选取p标签的第一个节点  )

Gets the offset of the matching element relative to the parent element.

2.4 scrollleft () and ScrollLeft (Val)

Gets the offset to the left of the matching element relative to the scrollbar.

3. Dimensions

3.1 Width () and width (val)

Height () and height (val)

3.2 innerwidth () and Innerheight () gets the length and width of objects that do not include borders

3.3 Outerheight (Boolean) Outerwidth (Boolean) If true, the bounding rectangle is calculated instead of

CSS in jquery

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.