These methods are used to manipulate CSS specially by getting and setting CSS-related properties of elements.
.css( )
This method get the CSS style property of the first matched element..
Example :
|
Above code display the color code of the clicked 'div' .
.height( )
This method get the height of the first matched element.
Example :
$("p").height()); // returns height of paragraph.
|
.innerWidth( )
This method return the width for the first element including padding but not border. This method is not applicable to window and document objects; for these, use .height() instead.
Example :
Following code will get the innerWidth of a paragraph :
|
.offset( )
This method get the current coordinate of the matched element, relative to the document.
Example :
This method returns the offset of the second paragraph
|
.outerHeight( )
This method get the outer Height from the first matched element, including padding and border.This method is not applicable to window and document objects; for these, use .height() instead.Example :
The following code get the outer Height of a paragraph :
|
.outerWidth( )
This method get the outer width from the first matched element, including padding and border.This method is not applicable to window and document objects; for these, use .height() instead.
Example :
The following code get the outer Width of a paragraph :
|
.position( )
This method get the coordinates of the first matched element , relative to the offset parent.
Example :
Following code return the position of the second paragraph :
<body> |
.scrollLeft( )
This method get the current horizontal position of the scroll bar for the first matched element.
Example :
Following code get the current horizontal position of the scroll bar for the first 'p' :
|
.scrollTop( )
This method get the current vertical position of the scroll bar for the first matched element.
Example :
Following code get the current vertical position of the scroll bar for the first 'p' :
|
.width( )
This method get the width of the first matched element.
Example :
Following are some example of 'width()' method :
$("p").width());
//returns width of paragraph.
$(window).width(); // returns width of browser viewport
$(document).width(); // returns width of HTML document
Learn from experts! Attend jQuery Training classes.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Working with CSS(CSS Manipulation)
Post your Comment