Sets the element's width and height.
Calling myElement.size() without an argument returns the element's size as an object with the properties width and height. For example, { width: 20, height: 10 }.
The first parameter, width, is optional. It's a number used to set the element's width. Calling myElement.size(10)
The second parameter, 'height, is also optional. It's a number used to set the element's height. For example, calling myElement.size(20, 10)` sets the element's width to 20 pixels and height to 10 pixels.
The constant AUTO can be used to adjust one dimension at a time while maintaining the aspect ratio, which is width / height. For example, consider an element that's 200 pixels wide and 100 pixels tall. Calling myElement.size(20, AUTO) sets the width to 20 pixels and height to 10 pixels.
Note: In the case of elements that need to load data, such as images, wait to call myElement.size() until after the data loads.
Ejemplos
Sintaxis
size()
size([w], [h])
Parámetros
width of the element, either AUTO, or a number.
height of the element, either AUTO, or a number.