javascript : Dom Elements .hide()

 

javascript : DomElements .hide()


Target:

Applicable with any DOM element.

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

Description :

set dom element style display none.


Note: after setting the style display of element/elements list it return itself for further processing.


Syntax:

DOMElement.hide()

DOMNodeList.hide()

HTMLCollection.hide()


Usase:

  1. document.getElementById('firstDiv').hide()
    it hides the div having id firstDiv and return firstDiv element
  2. document.getElementsByTagName('div').hide()
    the getElementsByTagName selects all div and hide() method hides all divs and return getElementsByTagName result for further processing you do not need to execute selector again.
  3. document.getElementsByClassName('FirstDiv').hide()
    the getElementsByClassName selects all div having class "FirstDiv" and hide() method hides all divs and return getElementsByClassName result for further processing you do not need to execute selector again.
  4. document.getElementsByName('FirstDiv').hide()
    the getElementsByName selects all elements having name attribute "FirstDiv" and hide() method hides all elements and return getElementsByName result for further processing you do not need to execute selector again.
  5. document.querySelector('.FirstDiv').hide()
    the querySelector selects first div having class "FirstDiv" and hide() method hide it and return querySelector result for further processing you do not need to execute selector again.
  6. document.querySelectorAll('.FirstDiv').hide()
    the querySelectorAll selects all div having class "FirstDiv" and hide() method hides all divs and return querySelectorAll result for further processing you do not need to execute selector again.



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()