Enter a search term above to see results...
On This Page
Query - Dimensions
The Dimension methods in Query provide tools for getting and setting various dimensional properties of elements, including their size, position, and scroll-related attributes.
width
Gets or sets the width of elements.
Syntax
Get
Set
Parameters
Name | Type | Description |
---|---|---|
value | number/string | The width to set for the element(s) |
Returns
Get
- Single Element - The width of that element in pixels.
- Multiple Elements - An array of widths, one for each matched element.
Set
Query object (for chaining).
Usage
Get Width
Set Width
height
Gets or sets the height of elements.
Syntax
Get
Set
Parameters
Name | Type | Description |
---|---|---|
value | number/string | The height to set for the element(s) |
Returns
Get
- Single Element - The height of that element in pixels.
- Multiple Elements - An array of heights, one for each matched element.
Set
Query object (for chaining).
Usage
Get Height
Set Height
scrollTop
Gets or sets the vertical scroll position of elements.
Syntax
Get
Set
Parameters
Name | Type | Description |
---|---|---|
value | number | The vertical scroll position to set in pixels |
Returns
Get
- Single Element - The vertical scroll position of that element in pixels.
- Multiple Elements - An array of vertical scroll positions, one for each matched element.
Set
Query object (for chaining).
Usage
Get Scroll Position
Set Scroll Position
scrollLeft
Gets or sets the horizontal scroll position of elements.
Syntax
Get
Set
Parameters
Name | Type | Description |
---|---|---|
value | number | The horizontal scroll position to set in pixels |
Returns
Get
- Single Element - The horizontal scroll position of that element in pixels.
- Multiple Elements - An array of horizontal scroll positions, one for each matched element.
Set
Query object (for chaining).
Usage
Get Scroll Position
Set Scroll Position
naturalWidth
Gets the natural width of an element, including images and other HTML elements.
Natural Width - This method works by creating a clone of the element, positioning it off-screen, and measuring its dimensions. While this approach allows for accurate measurements of complex elements like tables, it can cause a reflow in the document. Use judiciously, especially in performance-critical situations.
Syntax
Get
Returns
Get
- Single Element - The natural width of the element in pixels.
- Multiple Elements - An array of natural widths, one for each matched element.
Usage
Get Natural Width
naturalHeight
Gets the natural height of an element, including images and other HTML elements.
Syntax
Get
Returns
Get
- Single Element - The natural height of the element in pixels.
- Multiple Elements - An array of natural heights, one for each matched element.