/*! DOM access methods via the [`dom::Element`](struct.Element.html). ## Introduction. Let’s assume you have already integrated Sciter in your application and so you have a Sciter window with the loaded content. From Sciter's point of view the loaded document is a tree of DOM elements (elements of Document Object Model). Sciter builds this tree while loading/parsing of input HTML. As a rule, each tag in the source HTML is matching with a DOM element (there are exceptions, see below). You can change the text, attributes, state flags of DOM elements; add new or remove existing DOM elements. You can also attach your own DOM event handlers to DOM elements in order to receive events and notifications. Therefore your UI in Sciter is a collection of uniform DOM elements that can be styled by CSS and manipulated by native or script code. ## Basic operations To access the DOM tree we need to get a reference of its root element (the root element is the element representing the `` tag in HTML source). ```rust,no_run # use sciter::dom::Element; # let hwnd = ::std::ptr::null_mut(); let root = Element::from_window(hwnd).unwrap(); assert_eq!(root.get_tag(), "html"); ``` *TBD:* Other ways to access DOM tree. By having a root element reference we are able to access any other element in the tree using various access and search functions like `SciterGetNthChild`, `SciterSelectElements`, etc. All of them are wrapped into methods of [`dom::Element`](struct.Element.html). Here is how you would get a reference to the first `
element el.append(&p); // append it to the existing element, or use insert() ... ``` And in script: ```tiscript var p = new Element("p", "Hello"); el.append(p); ``` To change runtime state flags of a DOM element we do something like this: ```rust,ignore # let mut el = sciter::dom::Element::from(::std::ptr::null_mut()); el.set_state(ELEMENT_STATE_BITS::STATE_VISITED); ``` And in script: ```tiscript el.state.visited = true; ``` (after such call the element will match the `:visited` CSS selector) ## Getting and setting values of DOM elements. By default the value of a DOM element is its text but some DOM elements may have so called behaviors attached to them (see below). `` elements, for example, are plain DOM elements but each input type has its own behavior assigned to the element. The behavior, among other things, is responsible for providing and setting the value of the element. For example, the value of an `` is boolean – _true_ or _false_, and the value of a `