CSS
This article is simple. You can find APIs such as background and color when you view previous documents, but you cannot find them in Versions later than 1.2. Still use CSS () directly ....
CSS
CSS (name ):Access the style attribute of the First Matching Element
Example: $ ("p" ).css ("color ");
CSS (properties ):Set"Name/value pair"The object is set to the style attribute of all matching elements.
Example: $ ("P" ).css ({color: "# ff0011", Background: "blue "});
If the property name contains"-"Words,Quotation marks are required: $ ("P" ).css ({"margin-left": "10px", "background-color": "blue "});
CSS (name, value):Among all matched elements,Set the value of a style attribute,The number is automatically converted to the pixel value.
Example: $ ("P" ).css ("color", "Red ");
Location
Offset ():Obtains the relative offset of the matching element in the current view. The returned object contains two integer attributes: Top and left. This method is only valid for visible elements.
<P> Hello </P> <p> 2nd paragraph </P>
Code:
VaR P = $ ("P: Last ");
VaR offset = P. offset ();
P.html ("Left:" + offset. Left + ", top:" + offset. Top );
Result: <P> Hello </P> <p> left: 0, top: 35 </P>
Width and height
Height ():Obtains the height calculated for the First Matching Element.(PX). Can be used to obtainWindowAndDocumentHigh
Code: $ ("P"). Height ();
Code: $ (Document). Height ();//Retrieve document height
Height (VAL):Set for each Matching ElementCSSHeight(Hidth)Attribute Value. If the unit (such as em or %) is not explicitly specified, PX is used.
Code: $ ("p"). Height (20 );
Width ():Obtains the current calculated width (PX) of the First Matching Element ). Can be used to obtain the height of the window and document
Width (VAL ):Set the CSS width attribute value for each matching element.