Struct Element

A html element

struct Element ;

Properties

NameTypeDescription
children[set] autoAll the children contained in this element. (non-deep search)
contains[set] boolCheck if this element contains another one
descendants[set] autoAll the children contained in this element. (deep search)
firstChild[set] ElementThe first child
getAttribute[set] stringGet an attribute
hasAttribute[set] boolCheck if an attribute exists
id[get] stringThe id of this element (if present)
innerHTML[set] stringSet the html content of this element
innerHTML[get] stringGet the content of this element
innerText[get] stringSet the inner text of this element (replacing html)
innerText[set] stringGet the inner text of this element (ignoring html tags)
isAncestorOf[set] boolCheck if this element is the ancestor of another one
isDescendantOf[set] boolCheck if this element is the descendant of another one
isEmpty[get] boolIs this element empty?
isValid[get] boolIs this element valid?
lastChild[set] ElementThe last child
name[get] stringThe tag name of this element. For example "p" or "div"
next[set] ElementThe next element in the document
outerHTML[get] stringThe outer html of this element
outerHTML[set] stringSet the outer html of this element
owner[get] DocumentThe owner of this element
parent[get] ElementThe parent element
prev[set] ElementThe previous element in the document
removeAttribute[set] stringRemove an attribute from this element
setAttribute[set] stringSet an attribute for this element

Methods

NameDescription
appendChild (el) Put a new child in the last position
appendSibling (el) Append an element
attributes () Return a lazy range of attributes for this element
byClass (name) Search for elements by class
byComment (comment, stripSpaces) Search for elements by comment
byId (id) Search for elements by id
bySelector (selector) Search for elements by selector
byTagName (name) Search for elements by tag name
classes (, ) All the classes of this element
copyFrom (e, deep) Copy another element here
dup (deep) Clone this element
prependChild (el) Put a new child in the first position
prependSibling (el) Prepend an element
remove () Remove this element from the document
replaceWith (el) Replace this element with another one
toString (deep) Convert this element to a string

Inner structs

NameDescription
Attribute A simple key/value struct representing a html attribute