HTML DOM Document
The document object provides a number of properties and methods that allow web developers to access and manipulate various aspects of the document, such as the document's title, URL, and various HTML elements.
For example, the document.getElementById() method can be used to retrieve an element in the HTML document by its unique ID, while the document.getElementsByTagName() method can be used to retrieve a collection of elements in the HTML document with a specified tag name.
Other methods and properties of the document object can be used to dynamically create, modify, and delete HTML elements, manipulate the styles and content of elements, and respond to user interactions and events on the page.
This method returns the HTML element with the specified id attribute.
This method returns a collection of all HTML elements with the specified tag name.
This method creates a new HTML element with the specified tag name.
The createTextNode() method is used to create a new text node in the HTML DOM. It creates a new text node with the specified text as its content, and returns the newly created text node.
The document.write() method is used to write content directly into the HTML document at the time it is being parsed.
The addEventListener() method is used to attach an event listener to an HTML element. It allows you to specify a function (known as an event handler) that will be executed when a particular event occurs on the element.
This method is used when you no longer want the event listener to be triggered for that element. This can be useful when you want to prevent memory leaks or if you want to remove event listeners that are no longer needed.
The open() method is used to open a new browser window or tab, and the document.write() method is used to write HTML content to the new document.
Once you have finished writing content to the new document, you can use the close() method to close the document and display it in the new window or tab.
The createAttribute() method is used to create a new attribute node with the specified name. This method is part of the Document interface of the DOM (Document Object Model), which represents the HTML or XML document in the browser.
The getElementsByClassName() method is a built-in function that is used to select and retrieve a list of HTML elements that have a specific class name. It returns a live HTMLCollection object, which is a collection of all the elements in the current document that match the specified class name.
The getElementsByName() method is used to select and retrieve a list of HTML elements that have a specific name attribute. It returns a live NodeList object, which is a collection of all the elements in the current document that match the specified name attribute.
The querySelector() method is used to select and retrieve the first element within the current document that matches a specified CSS selector. It returns a reference to the selected element, or null if no matching element is found.
The querySelectorAll() method is used to select and retrieve all elements within the current document that match a specified CSS selector. It returns a NodeList object, which is a collection of all the elements in the current document that match the specified selector.
It is a property of the document object that represents the title of the current HTML document.
The body property is a property of the document object that represents the <body> element of an HTML document. It provides access to the content within the <body> tags of the document.
The document.cookie property is used to read and write cookies associated with the current document.
The document.URL property returns the entire URL of the current page, including the protocol, domain, port number (if specified), path, and any query parameters. This property can be used to read or change the URL of the current page, which can be useful for various tasks such as redirecting the user to a different page or updating the URL in the address bar.