DOM
With the DOM, Python can access and change all the elements of window.
DOM methods are actions you can perform (on Elements).
DOM properties are values (of Elements) that you can set or change.
The DOM Programming Interface
The DOM can be accessed with Python.
In the DOM, all elements are defined as objects.
The programming interface is the properties and methods of each object.
A property is a value that you can get or set (like changing the content of an element).
A method is an action you can do (like add or deleting an element).
Example
In the example above, getElementById
is a method, while innerHTML
is a property.
The getElementById Method
The most common way to access an element is to use the id
of the element.
In the example above the getElementById
method used id="demo"
to find the element.
The innerHTML Property
The easiest way to get the content of an element is by using the innerHTML
property.
The innerHTML
property is useful for getting or replacing the content of elements.
The innerHTML
property can be used to get or change any element.
Document
The HTML DOM document object is the owner of all other objects in your UI.
The HTML DOM Document Object
The document object represents your UI.
If you want to access any element, you always start with accessing the document object.
Below are some examples of how you can use the document object to access and manipulate HTML.
Finding HTML Elements
Changing HTML Elements
Adding and Deleting Elements
Adding Events Handlers
Above method is Not supported yet. Instead use
document.getElementById(id).addEventHandler(event, handler)
Last updated