Appendix H. CSS
Method | Description | Return Value |
---|---|---|
CSS | ||
| Returns the specified CSS property value from the first selected element, for example: $('div').css('background-color') | String |
| Sets the specified CSS properties. The $('div').css({ backgroundColor: 'red', marginLeft: '10px' }); | jQuery |
| Sets the specified CSS property value, for example: $('div').css('background', 'red'); | jQuery |
Positioning | ||
| Returns the offset position of the first selected element relative to the viewport. var $offset = $('div').offset(); alert('Left: ' + $offset.left); alert('Top: ' + $offset.top); | Object |
Height and Width | ||
| Returns the pixel height (CSS height, excluding borders and padding) of the first selected element. | Integer |
| Sets the pixel height (CSS height) of the first selected element. If no unit of measurement is provided, px (pixels) is used. | jQuery |
| Returns the pixel width (CSS width, excluding borders and padding) of the first selected element. | Integer |
| Sets the pixel width (CSS width) of the first selected element. If no unit of measurement is provided, px (pixels) is used. | jQuery |
| Returns the | Integer |
|
Get Beginning JavaScript® and CSS Development with jQuery now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.