Custom Type to allow all of its methods to be used with any DOM element via the dollar function $.
Scrolls the element to the specified coordinated (if the element has an overflow). The following method is also available on the Window object.
myElement.scrollTo(x, y);
$('myElement').scrollTo(0, 100);
Returns the height and width of the Element, taking into account borders and padding. The following method is also available on the Window object.
myElement.getSize();
var size = myElement.getSize(); alert('The element is ' + size.x + ' pixels wide and ' + size.y + 'pixels high.');
If you need to measure the properties of elements that are not displayed (either their display style is none or one of their parents display style is none), you will need to use Element.measure to expose it.
Returns an Object representing the size of the target Element, including scrollable area. The following method is also available on the Window object.
myElement.getScrollSize();
var scroll = $('myElement').getScrollSize(); alert('My element can scroll to ' + scroll.y + 'px'); // alerts 'My element can scroll down to 820px'
If you need to measure the properties of elements that are not displayed (either their display style is none or one of their parents display style is none), you will need to use Element.measure to expose it.
Returns an Object representing how far the target Element is scrolled in either direction. The following method is also available on the Window object.
myElement.getScroll();
var scroll = $('myElement').getScroll(); alert('My element is scrolled down ' + scroll.y + 'px'); // alerts 'My element is scrolled down to 620px'
If you need to measure the properties of elements that are not displayed (either their display style is none or one of their parents display style is none), you will need to use Element.measure to expose it.
Returns the real offsets of the element.
myElement.getPosition(relative);
relative - (Element, defaults to the document) If set, the position will be relative to this Element.
$('element').getPosition(); // returns {x: 100, y: 500};
If you need to measure the properties of elements that are not displayed (either their display style is none or one of their parents display style is none), you will need to use Element.measure to expose it.
Sets the position of the element's left and top values to the x/y positions you specify.
myElement.setPosition(positions);
myElement.setPosition({x: 10, y: 100});
Returns an object with width, height, left, right, top, and bottom coordinate values of the Element.
myElement.getCoordinates(relative);
relative - (element, optional) if set, the position will be relative to this element, otherwise relative to the document.
var myValues = $('myElement').getCoordinates();
{ top: 50, left: 100, width: 200, height: 300, right: 300, bottom: 350 }
If you need to measure the properties of elements that are not displayed (either their display style is none or one of their parents display style is none), you will need to use Element.measure to expose it.
Returns the parent of the element that is positioned, if there is one.
myElement.getOffsetParent();
© Linux.ria.ua, 2008-2024 |