Extends the Element Type with some basic shortcuts (like .hide and .show).
Tutorial/Demo
Returns the state of the display of the element.
Syntax
myElement.isDisplayed();
Returns
- (boolean) true if display != "none", false if display == "none".
Determines if an element is displayed using offset height/width. If both of these are zero it usually means the element is not displayed or one of its parent's is not.
Syntax
myElement.isVisible();
Returns
- (boolean) true if visible, false if not visible.
Toggles the state of an element from hidden (display = none) to visible (display = what it was previously or else display = block)
Syntax
myElement.toggle();
Returns
- (element) This Element.
Hides an element (display = none).
Example
myElement.hide(); //same as $(id).setStyle('display', 'none');
Returns
- (element) This Element.
Shows an element.
Syntax
myElement.show(displayString);
Arguments
- displayString - (string) Display value; defaults to what it was previously if Element:hide was called on the element, otherwise defaults to "block".
Returns
- (element) This Element.
Example
$(id).show(); //same as $(id).setStyle('display', 'block');
$(id).show('inline'); //same as $(id).setStyle('display','inline');
Removes one class and adds the other. If the one to remove is not found the one to add is still added.
Syntax
myElement.swapClass(removeClass, addClass);
Arguments
- removeClass - (string) the css class to remove.
- addClass - (string) the css class to add.
Returns
- (element) This Element.
Example
$(id).swapClass('green', 'blue'); // removes green, adds blue
Removes any document selection (text selection). Can only be called on document.
Syntax
document.clearSelection();
Returns
- nothing