Interface NonElementParentNode
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.
[Value("NonElementParentNode")]
public interface NonElementParentNode
Remarks
The DOM tree includes elements such as body and table, among many others. It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document.
The Document interface describes the common properties and methods for any kind of document. Depending on the document's type (e.g., HTML, XML, SVG, …), a larger API is available: HTML documents, served with the "text/html" content type, also implement the HTMLDocument interface, whereas XML and SVG documents implement the XMLDocument interface.
Methods
GetElementById(string)
The getElementById() method of the Document interface returns an Element object representing the element whose Id property matches the specified string. Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.
[Value("getElementById")]
Element? GetElementById(string elementId)
Parameters
elementIdstring
Returns
- Element
An Element object describing the DOM element object matching the specified ID, or
nullif no matching element was found in the document.
Remarks
If you need to get access to an element which doesn't have an ID, you can use Document.QuerySelector to find the element using any {{Glossary("CSS selector", "selector")}}.
NOTE
IDs should be unique inside a document. If two or more elements in a document have the same ID, this method returns the first element found.
-Document reference for other methods and properties you can use to get references to elements in the document.
-Document.QuerySelector for selectors via queries like 'div.myclass'
-Document.Evaluate - has a utility method for selecting by xml:id in XML documents