javascript : DomElement .text()

 

javascript : DomElement .text()


Target:

Applicable with any DOM element having attribute innerText.

  • getElementById
  • getElementsByTagName
  • getElementsByClassName
  • getElementsByName
  • querySelector
  • querySelectorAll

In case of DOM NodeList first Node Element is processed for get innerText.


Description :

get innerText of DOM element.



Syntax:

DOMElement.text()

DOMNodeList.text()

HTMLCollection.text()


Usase:

  1. document.getElementById('firstDiv').text()
    it returns the innerText of firstDiv, that is "welcome"
  2. document.querySelector('#firstDiv').text()
    it returns the innerText of firstDiv, that is "welcome"
  3. document.querySelectorAll('div').text()
    it returns the innerHTML of first div's, that is "welcome"
  4. document.getElementsByTagName('div').text()
    it returns the innerHTML of first div's, that is "welcome"



Download MYJS.js

MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type. 

Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

Comments

Popular posts from this blog

javascript : String.right

javascript : String.left

javascript : .nextAll()