Category: JavaScript DOM

  • Javascript – innerText

    The innerText property can be used to write the dynamic text on the html document. Here, text will not be interpreted as html text but a normal text. It is used mostly in the web pages to generate the dynamic content such as writing the validation message, password strength etc. Javascript innerText Example In this example, we…

  • Javascript – document.getElementsByTagName() method

    The document.getElementsByTagName() method returns all the element of specified tag name. The syntax of the getElementsByTagName() method is given below: Here, name is required. Example of document.getElementsByTagName() method In this example, we going to count total number of paragraphs used in the document. To do this, we have called the document.getElementsByTagName(“p”) method that returns the total paragraphs.…

  • GetElementsByClassName()

    The getElementsByClassName() method is used for selecting or getting the elements through their class name value. This DOM method returns an array-like object that consists of all the elements having the specified classname. On calling the getElementsByClassName() method on any particular element, it will search the whole document and will return only those elements which…

  • Javascript – document.getElementById() method

    The document.getElementById() method returns the element of specified id. In the previous page, we have used document.form1.name.value to get the value of the input value. Instead of this, we can use document.getElementById() method to get value of the input text. But we need to define id for the input field. Let’s see the simple example of document.getElementById() method that…

  • Document Object Model

    The document object represents the whole html document. When html document is loaded in the browser, it becomes a document object. It is the root element that represents the html document. It has properties and methods. By the help of document object, we can add dynamic content to our web page. As mentioned earlier, it is the object of…