Javascript DOM Element
Javascript examples for DOM:Element
HOME
Javascript
DOM
Element
Description
Click the following links for the tutorial for DOM and Element.
Element clientHeight Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth, when we add a scrollbar to the element:
Element clientHeight Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth:
Element clientHeight Property
Element classList Property - Toggle between classes to create a dropdown button:
Element classList Property - Find out if an element has a "mystyle" class. If so, remove another class name:
Element classList Property - Find out if an element has a "mystyle" class:
Element classList Property - Get the first class name (index 0) of a <div> element:
Element classList Property - Find out how many class names a <div> element has:
Element classList Property - Get the class name(s) of a <div> element:
Element classList Property - Toggle between two classes for a <div> element:
Element classList Property - Remove multiple classes from a <div> element:
Element classList Property - Remove a class from a <div> element:
Element classList Property - Add multiple classes to a <div> element:
Element classList Property
Element children Property - Loop through all children of <body> and change their background color to red:
Element children Property - Get the text of the third child element (index 2) of a <select> element:
Element children Property - Change the background color of the second child element of a <div> element:
Element children Property - Find out how many children a <div> element has:
Element children Property
Element childElementCount Property
Element offsetWidth Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth, when we add a scrollbar to the element:
Element offsetWidth Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth:
Element offsetWidth Property
Element offsetTop Property - Get the position of a a <div> element:
Element offsetTop Property
Element offsetParent Property
Element offsetLeft Property - Get the position of a a <div> element:
Element offsetLeft Property
Element offsetHeight Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth, when we add a scrollbar to the element:
Element offsetHeight Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth:
Element offsetHeight Property
Element nextElementSibling Property
Element lastElementChild Property - Get the text of the last child element of a <select> element:
Element lastElementChild Property - Get the tag name of the last child element of a <div> element:
Element lastElementChild Property
Element firstElementChild Property - Get the text of the first element node of a <select> element:
Element firstElementChild Property - Get the tag name of the first child element of a <div> element:
Element firstElementChild Property
Element clientWidth Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth, when we add a scrollbar to the element:
Element clientWidth Property - difference between clientHeight/clientWidth and offsetHeight/offsetWidth:
Element clientWidth Property
Element clientTop Property
Element clientLeft Property - Get the border size for a <div> with scrollbar:
Element clientLeft Property
Element tagName Property - Using the tagName property together with the event.target property to find out which element triggered a specified event:
Element tagName Property
Element scrollWidth Property - Return the scrollHeight and scrollWidth of an element and then set its height and width to the values returned from scrollHeight and scrollWidth:
Element scrollWidth Property - Using padding, border, scrollbar and margin to show how this affects the scrollWidth and scrollHeight property:
Element scrollWidth Property
Element scrollTop Property - Slide in an element when the user has scrolled down 350 pixels from the top of the page
Element scrollTop Property - Toggle between class names on different scroll positions
Element scrollTop Property - Scroll the contents of <body> by 30 pixels horizontally and 10 pixels vertically:
Element scrollTop Property - Scroll the contents of a <div> element BY 50 pixels horizontally and 10 pixels vertically:
Element scrollTop Property - Scroll the contents of a <div> element TO 50 pixels horizontally and 10 pixels vertically:
Element scrollTop Property
Element scrollLeft Property - Scroll the contents of <body> by 30 pixels horizontally and 10 pixels vertically:
Element scrollLeft Property - Scroll the contents of a <div> element BY 50 pixels horizontally and 10 pixels vertically:
Element scrollLeft Property - Scroll the contents of a <div> element TO 50 pixels horizontally and 10 pixels vertically:
Element scrollLeft Property
Element scrollHeight Property - Return the scrollHeight and scrollWidth of an element and then set its height and width to the values returned from scrollHeight and scrollWidth:
Element scrollHeight Property - Using padding, border, scrollbar and margin to show how this affects the scrollWidth and scrollHeight property:
Element scrollHeight Property
Element previousElementSibling Property
Element title Property - Change the title of a <p> element:
Element title Property
Element tabIndex Property - Get the tab order of the first <a> element (index 0) in the document:
Element tabIndex Property
Element style Property - Add a red color to an <h1> element:
Element style Property - Get the value of a <p> element's top-border:
Element style Property
Element lang Property
Element isContentEditable Property
Element innerHTML Property - Change the HTML content, URL, and target of a link:
Element innerHTML Property - Delete the HTML content of a <p> element with id="demo":
Element innerHTML Property - Alert the HTML content of a <p> element with id="demo":
Element innerHTML Property - Get the HTML content of a <ul> element with id="myList":
Element innerHTML Property - Get the HTML content of a <p> element with id="myP":
Element innerHTML Property
Element id Property - If the first <div> element in the document has an id of "myDIV", change its font-size:
Element id Property - Change the id of an element:
Element id Property
Element dir Property - Get the text direction of a <p> element:
Element dir Property
Element contentEditable Property - Toggle between the ability to edit the content of a <p> element:
Element contentEditable Property - Find out if a <p> element is editable or not:
Element contentEditable Property
Element className Property - Toggle between class names on different scroll positions
Element className Property - Toggle between two class names.
Element className Property - check class name
Element className Property - To add a class to an element, without overwriting existing values
Element className Property - Overwriting an existing class name with a new one:
Element className Property - Get the class names of an element with multiple classes:
Element className Property - get the class name of an element:
Element className Property - Get the class name of the first <div> element in the document
Element className Property
Element accessKey Property - Get the accesskey of a link:
Element accessKey Property
Element childNodes Property - Get the text of the third child node (index 2) of a <select> element:
Element childNodes Property - Change the background color of the second child node (index 1) of a <div> element:
Element childNodes Property - Find out how many child nodes a <div> element has:
Element childNodes Property
Element attributes Property - Loop through all attributes of an <img> element and output each attribute's name and value:
Element attributes Property - Find out how many attributes an <img> element have:
Element attributes Property - Get the name of a <button> element's second (index 1) attribute:
Element attributes Property
Element NodeList Property - Loop through the child nodes of <body> and output the node name of each child node:
Element NodeList Property - Return the number of child nodes of the <body> element:
Element NodeList Property - Loop through all <p> elements inside a <div> element, and change the background color of each <p>:
Element NodeList Property - Find out how many <p> elements there are inside a <div> element:
Element NodeList length Property
Element textContent Property - differences between the textContent and innerHTML property:
Element textContent Property - Get all the textual content of an <ul> element with id="myList":
Element textContent Property - Change the textual content of a <p> element with id="myP":
Element textContent Property
Element previousSibling Property
Element parentNode Property - Click on an element (<span>) to hide its parent node (<div>):
Element parentNode Property
Element parentElement Property - Click on an element (<span>) to hide its parent element (<div>):
Element parentElement Property
Element ownerDocument Property
Element nodeValue Property - Get the node name, node value and the node type of the <div> element's first child node:
Element nodeValue Property
Element nodeName Property - Get the node name, node value and the node type of the <div> element's first child node:
Element nodeName Property - Get the node types of the <body> element's child nodes:
Element nodeName Property - Get the node type of the <body> element:
Element nodeType Property
Element nodeName Property - Get the node names of the <body> element's child nodes:
Element nodeName Property - Get the node name of the <body> element:
Element nodeName Property
Element nextSibling Property
Element namespaceURI Property
Element setAttributeNode() Method - Set the href attribute node of a <a> element:
Element setAttributeNode() Method
Element setAttribute() Method - Find out if an <a> element has a target attribute. If so, change the value of the target attribute to "_self":
Element setAttribute() Method - Add a href attribute with a value of "book2s.com" to an <a> element:
Element setAttribute() Method - Change class attribute for h1
Element setAttribute() Method
Element scrollIntoView() Method
Element removeEventListener() Method - If browsers do not support removeEventListener() method, use the detachEvent() method.
Element removeEventListener() Method
Element removeAttributeNode() Method
Element removeAttribute() Method - Remove the href attribute from an <a> element:
Element removeAttribute() Method
Element querySelectorAll() Method - Set the background color of all <h2>, <div> and <span> elements
Element querySelectorAll() Method - Set the border style of all <a> elements in a <div> element that have a "target" attribute:
Element querySelectorAll() Method - Set the background color of all <p> elements in a <div> element:
Element querySelectorAll() Method - Set the background color of all elements with class="example" in a <div> element:
Element querySelectorAll() Method - Find out how many elements with class="example" there are in a <div> element
Element querySelectorAll() Method - Get all <p> elements in a <div> with class="example", and set the background of the first <p> element:
Element querySelectorAll() Method - Get all <p> elements inside a <div> element, and set the background color of the first <p> element (index 0):
Element querySelectorAll() Method
Element querySelector() Method - Use multiple selectors in querySelector()
Element querySelector() Method - Add a red border to the first <a> element that has a target attribute inside a <div> element:
Element querySelector() Method - Change the color of paragraph element in a <div> element:
Element querySelector() Method - Change the text of the first <p> element with class="example" in a <div> element:
Element querySelector() Method - Change the text of the first <p> element in a <div> element:
Element querySelector() Method
Element hasAttribute() Method
Element getElementsByTagName() Method - Using the "*" parameter, Change the background color of all elements inside a <div> element:
Element getElementsByTagName() Method - Change the background color of the fourth element (index 3) inside a <div> element:
Element getElementsByTagName() Method - Change the background color of all <p> elements inside a <div> element:
Element getElementsByTagName() Method - Change the background color of the second <p> element (index 1) inside a <div> element:
Element getElementsByTagName() Method - Find out how many <p> elements there are inside a <div> element
Element getElementsByTagName() Method
Element getElementsByClassName() Method - Change the background color of all elements with class="child" inside of a <div> element:
Element getElementsByClassName() Method - Change background color of the first element with both the "child" and "color" class
Element getElementsByClassName() Method - Find out how many elements with class="child" there are inside of a <div> element
Element getElementsByClassName() Method - Change the background color of the second element with class="child" inside of a <div> element:
Element getElementsByClassName() Method
Element getAttributeNode() Method - Get the value of the onclick attribute node of a <button> element:
Element getAttributeNode() Method - Get the value of the target attribute node of an <a> element:
Element getAttributeNode() Method
Element getAttribute() Method - Get the value of the onclick event attribute of a <button> element:
Element getAttribute() Method - Get the value of the target attribute of an <a> element:
Element getAttribute() Method
Element addEventListener() Method - If browsers that don't support addEventListener() method, use the attachEvent() method.
Element addEventListener() Method - Use removeEventListener() method to remove an event handler attached with the addEventListener() method:
Element addEventListener() Method - Using useCapture parameter to demonstrate the difference between bubbling and capturing:
Element addEventListener() Method - Change the background color of a <button> element:
Element addEventListener() Method - Pass parameter values when using the addEventListener() method
Element addEventListener() Method - Add events of different types to the same element.
Element addEventListener() Method - Add two click events on the same <button> element:
Element addEventListener() Method - Execute a function when a user clicks on a <button> element:
Element addEventListener() Method
Element focus() Method - Give focus to a text field, immediately after the document window has been loaded:
Element focus() Method - Give focus to a text field:
Element focus() Method
Element click() Method
Element blur() Method - Remove focus from a text field:
Element blur() Method
Element item() Method - Loop through all elements with class="child" in a <div> element, and change their background color:
Element item() Method - Get the HTML content of the first <p> element (index 0) inside a <div> element:
Element item() Method - Use childNodes.item(index) to access child node
Element item() Method - Use childNodes[index] to access child node
Element item() Method
Element replaceChild Method
Element removeChild Method - Remove a <span> element from its parent and insert it to an <h1> element in another document:
Element removeChild Method - Remove a <li> element from its parent, and insert it again:
Element removeChild Method - Remove a <li> element with id="myLI" from its parent element
Element removeChild Method - Remove all child nodes of a list:
Element removeChild Method - Find out if a list has any child nodes. If so, remove its first child node (index 0):
Element removeChild Method
Element normalize Method
Element isSameNode Method - Using the === operator to check if two nodes are the same node:
Element isSameNode Method
Element isEqualNode Method
Element isDefaultNamespace Method
Element insertBefore Method - Move a <li> element from one list to another:
Element insertBefore Method
Element hasChildNodes Method - Remove the first child node (index 0) inside an <ul> element, if the element has any child nodes:
Element hasChildNodes Method
Element hasAttributes Method
Element contains() Method
Element compareDocumentPosition Method
Element cloneNode Method - Copy a <div> element, including all its attributes and child elements, and append it to the document:
Element cloneNode Method
Element appendChild() Method - Create a <p> element with some text and append it to the end of the document body:
Element appendChild() Method - Create a <p> element and append it to a <div> element:
Element appendChild() Method - Move a list item from one list to another:
Element appendChild() Method