Sets the element's position.
The first two parameters, x
and y
, set the element's position relative to the top-left corner of the web page.
The third parameter, positionType
, is optional. It sets the element's positioning scheme. positionType
is a string that can be either 'static'
, 'fixed'
, 'relative'
, 'sticky'
, 'initial'
, or 'inherit'
.
If no arguments passed, as in myElement.position()
, the method returns the element's position in an object, as in { x: 0, y: 0 }
.
Examples
Syntax
position()
position([x], [y], [positionType])
Parameters
x
Number:
x-position relative to top-left of window (optional)
y
Number:
y-position relative to top-left of window (optional)
positionType
String:
it can be static, fixed, relative, sticky, initial or inherit (optional)
Notice any errors or typos? Please let us know. Please feel free to edit src/dom/dom.js and open a pull request!