javascript : dom elements .show()

 

javascript : DomElements.show()


Target:

Applicable with any DOM element.

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

Description :

It remove dom element inline display style if currently "none". if after that applicable style is "none" then sets inline style to "block"


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


Syntax:

DOMElement.show()

DOMNodeList.show()

HTMLCollection.show()


Usase:

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