Provides DOM helper methods.
_bruteContainselement
needle
Brute force version of contains. Used for browsers without contains support for non-HTMLElement Nodes (textNodes, etc).
element
HTMLElement
The containing html element.
needle
HTMLElement
The html element that may be contained.
Whether or not the element is or contains the needle.
_getDocelement
returns the appropriate document.
element
HTMLElement
optional Target element.
The document for the given element or the default document.
_getRegExpstr
flags
Memoizes dynamic regular expressions to boost runtime performance.
An instance of RegExp
_getWinelement
returns the appropriate window.
element
HTMLElement
optional Target element.
The window for the given element or the default window.
addClasselement
className
Adds a class name to a given DOM element.
element
HTMLElement
The DOM element.
className
String
the class name to add to the class attribute
addHTMLnode
content
where
Inserts content in a node at the given location
node
HTMLElement
The node to insert into
content
HTMLElement | Array | HTMLCollection
The content to be inserted
where
HTMLElement
Where to insert the content If no "where" is given, content is appended to the node Possible values for "where"
byIdid
doc
Returns the HTMLElement with the given ID (Wrapper for document.getElementById).
The HTMLElement with the id, or null if none found.
containselement
needle
Determines whether or not one HTMLElement is or contains another HTMLElement.
element
HTMLElement
The containing html element.
needle
HTMLElement
The html element that may be contained.
Whether or not the element is or contains the needle.
createhtml
doc
Creates a new dom node using the provided markup string.
html
String
The markup used to create the element
doc
HTMLDocument
An optional document context
returns a single HTMLElement when creating one node, and a documentFragment when creating multiple nodes.
docScrollXAmount page has been scroll horizontally
The current amount the screen is scrolled horizontally.
docScrollYAmount page has been scroll vertically
The current amount the screen is scrolled vertically.
elementByAxiselement
axis
[fn]
[all]
Searches the element by the given axis for the first matching element.
element
HTMLElement
The html element.
axis
String
The axis to search (parentNode, nextSibling, previousSibling).
[fn]
Function
optional
An optional boolean test to apply.
[all]
Boolean
optional
Whether text nodes as well as element nodes should be returned, or just element nodes will be returned(default) The optional function is passed the current HTMLElement being tested as its only argument. If no function is given, the first element is returned.
The matching element or null if none found.
getAttributeel
attr
Provides a normalized attribute interface.
el
HTMLElement
The target element for the attribute.
attr
String
The attribute to get.
The current value of the attribute.
getComputedStylenode
att
Returns the computed style for the given node.
node
HTMLElement
The HTMLElement to get the style from.
att
String
The style property to get.
The computed value of the style property.
getScrollbarWidthGets the width of vertical scrollbars on overflowed containers in the body content.
Pixel width of a scrollbar in the current browser
getStylenode
att
[style]
Returns the current style value for the given property.
node
HTMLElement
The HTMLElement to get the style from.
att
String
The style property to get.
[style]
Object
optional
The style node. Defaults to node.style.
getTextelement
Returns the text content of the HTMLElement.
element
HTMLElement
The html element.
The text content of the element (includes text of any descending elements).
getXelement
Gets the current X position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
element
Object
The target element
The X position of the element
getXYelement
Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
element
Object
The target element
getYelement
Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
element
Object
The target element
The Y position of the element
hasClasselement
className
Determines whether a DOM element has the given className.
element
HTMLElement
The DOM element.
className
String
the class name to search for
Whether or not the element has the given class.
inDocelement
doc
Determines whether or not the HTMLElement is part of the document.
element
HTMLElement
The containing html element.
doc
HTMLElement
optional The document to check.
Whether or not the element is attached to the document.
inRegionnode
node2
all
altRegion
Check if any part of this node is in the passed region
node
Object
The node to get the region from
node2
Object
The second node to get the region from or an Object literal of the region
all
Boolean
Should all of the node be inside the region
altRegion
Object
An object literal containing the region for this node if we already have the data (for performance e.g. DragDrop)
True if in region, false if not.
intersectelement
element2
altRegion
Find the intersect information for the passed nodes.
element
HTMLElement
The first element
element2
HTMLElement | Object
The element or region to check the interect with
altRegion
Object
An object literal containing the region for the first element if we already have the data (for performance e.g. DragDrop)
Object literal containing the following intersection data: (top, right, bottom, left, area, yoff, xoff, inRegion)
inViewportRegionelement
all
altRegion
Check if any part of this element is in the viewport
element
HTMLElement
The DOM element.
all
Boolean
Should all of the node be inside the region
altRegion
Object
An object literal containing the region for this node if we already have the data (for performance e.g. DragDrop)
True if in region, false if not.
regionelement
Returns an Object literal containing the following about this element: (top, right, bottom, left)
element
HTMLElement
The DOM element.
Object literal containing the following about this element: (top, right, bottom, left)
removeClasselement
className
Removes a class name from a given element.
element
HTMLElement
The DOM element.
className
String
the class name to remove from the class attribute
replaceClasselement
oldClassName
newClassName
Replace a class with another class for a given element. If no oldClassName is present, the newClassName is simply added.
element
HTMLElement
The DOM element
oldClassName
String
the class name to be replaced
newClassName
String
the class name that will be replacing the old class name
setAttributeel
attr
val
Provides a normalized attribute interface.
el
HTMLElement
The target element for the attribute.
attr
String
The attribute to set.
val
String
The value of the attribute.
setHeightelement
size
Sets the height of the element to the given size, regardless of box model, border, padding, etc.
element
HTMLElement
The DOM element.
size
String | Number
The pixel height to size to
setStylenode
att
val
[style]
Sets a style property for a given element.
node
HTMLElement
The HTMLElement to apply the style to.
att
String
The style property to set.
val
String | Number
The value.
[style]
Object
optional
The style node. Defaults to node.style.
setStylesnode
hash
Sets multiple style properties.
node
HTMLElement
The HTMLElement to apply the styles to.
hash
Object
An object literal of property:value pairs.
setTextelement
content
Sets the text content of the HTMLElement.
element
HTMLElement
The html element.
content
String
The content to add.
setWidthelement
size
Sets the width of the element to the given size, regardless of box model, border, padding, etc.
element
HTMLElement
The DOM element.
size
String | Number
The pixel height to size to
setXelement
x
Set the X position of an html element in page coordinates, regardless of how the element is positioned. The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
setXYelement
xy
noRetry
Set the position of an html element in page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
setYelement
y
Set the Y position of an html element in page coordinates, regardless of how the element is positioned. The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
toggleClasselement
className
addClass
If the className exists on the node it is removed, if it doesn't exist it is added.
element
HTMLElement
The DOM element
className
String
the class name to be toggled
addClass
Boolean
optional boolean to indicate whether class should be added or removed regardless of current state
viewportRegionReturns an Object literal containing the following about the visible region of viewport: (top, right, bottom, left)
Object literal containing the following about the visible region of the viewport: (top, right, bottom, left)