.
Calls getElementById, but throws instead of returning null if the element is not found. You can also ask for a specific subclass of Element to dynamically cast to, which also throws if it cannot be done.
ditto but with selectors instead of ids
If a matching selector is found, it returns that Element. Otherwise, the returned object returns null for all methods.
get all the classes on this element
Adds a string to the class attribute. The class attribute is used a lot in CSS.
Removes a particular class name.
Returns whether the given class appears in this element.
convenience function to quickly add a tag with some text or other relevant info (for example, it's a src for an <img> element instead of inner text)
Another convenience function. Adds a child directly after the current one, returning the new child.
Convenience function to append text intermixed with other children. For example: div.addChildren("You can visit my website by ", new Link("mysite.com", "clicking here"), "."); or div.addChildren("Hello, ", user.name, "!"); See also: appendHtml. This might be a bit simpler though because you don't have to think about escaping.
.
.
.
Strips this tag out of the document, putting its inner html as children of the parent.
shorthand for this.parentNode.removeChild(this) with parentNode null check if the element already isn't in a tree, it does nothing.
Wraps this element inside the given element. It's like this.replaceWith(what); what.appendchild(this);
Replaces this element with something else in the tree.
Splits the className into an array of each class given
Fetches the first consecutive text nodes concatenated together.
Returns the text directly under this element.
Sets the direct text, without modifying other child nodes.
The name of the tag. Remember, changing this doesn't change the dynamic type of the object.
This is where the attributes are actually stored. You should use getAttribute, setAttribute, and hasAttribute instead.
Get the parent Document object that contains this element. It may be null, so remember to check for that.
.
Convenience function to try to do the right thing for HTML. This is the main way I create elements.
Returns the first child of this element. If it has no children, returns null. Remember, text nodes are children too.
.
.
Gets the nearest node, going up the chain, with the given tagName May return null or throw.
.
Note: you can give multiple selectors, separated by commas. It will return the first match it finds.
a more standards-compliant alias for getElementsBySelector
Returns elements that match the given CSS selector
.
.
Gets the given attribute value, or null if the attribute is not set.
Sets an attribute. Returns this for easy chaining
Returns if the attribute exists.
Removes the given attribute from the element.
Gets the class attribute's contents. Returns an empty string if it has no class.
.
Provides easy access to common HTML attributes, object style.
Old access to attributes. Use attrs instead.
Returns the element's children.
Mutable version of the same
HTML5's dataset property. It is an alternate view into attributes with the data- prefix. Given <a data-my-property="cool" />, we get assert(a.dataset.myProperty == "cool");
Gives dot/opIndex access to attributes
Provides both string and object style (like in Javascript) access to the style attribute.
This sets the style attribute with a string.
Don't use this.
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
Removes all inner content from the tag; all child text and elements are gone.
Appends the given element to this one. The given element must not have a parent already.
Inserts the second element to this node, right before the first param
Inserts the given element what as a sibling of the this element, after the element where in the parent node.
swaps one child for a new thing. Returns the old child which is now parentless.
Appends the given to the node.
Returns child elements which are of a tag type (excludes text, comments, etc.).
Appends the given html to the element, returning the elements appended
.
Reparents all the child elements of e to this, leaving e childless.
Puts the current element first in our children list. The given element must not have a parent already.
Returns a string containing all child elements, formatted such that it could be pasted into an XML file.
Takes some html and replaces the element's children with the tree made from the string.
Replaces this node with the given html string, which is parsed
Returns all the html for this element, including the tag itself.
This sets the inner content of the element *without* trying to parse it. You can inject any code in there; this serves as an escape hatch from the dom.
.
Replaces the given element with a whole group.
Removes the given child from this list.
This removes all the children from this element, returning the old list.
Fetch the inside text, with all tags stripped out.
Sets the inside text, replacing all children. You don't have to worry about entity encoding.
Strips this node out of the document, replacing it with the given text
Same result as innerText; the tag with all inner tags stripped out
This is a full clone of the element
Clones the node. If deepClone is true, clone all inner tags too. If false, only do this tag (and its attributes), but it will have no contents.
W3C DOM interface. Only really meaningful on TextNode instances, but the interface is present on the base class.
.
Turns the whole element, including tag, attributes, and children, into a string which could be pasted into an XML file.
Writes out with formatting. Be warned: formatting changes the contents. Use ONLY for eyeball debugging.
This is the actual implementation used by toString. You can pass it a preallocated buffer to save some time. Returns the string it creates.
Returns a lazy range of all its children, recursively.
Tags: HTML, HTML5
Represents anything that can be a table cell - <td> or <th> html.