javascript : .visible()

 

javascript : .visible()


Target:

Applicable with any DOM elements List.

  • getElementById
  • getElementsByTagName
  • getElementsByClassName
  • getElementsByName
  • querySelector
  • querySelectorAll
  • select
  • etc.

Description :

return DOMNodeList that are visible in selector.


Syntax:

DOMElement.visible()

DOMNodeList.visible()

HTMLCollection.visible()


Usase:

  1. document.getElementById('firstDiv').visible()
    if the div having id firstDiv is visible then return DOMNodeList having firstDiv
  2. document.getElementsByTagName('div').visible()
    the getElementsByTagName selects all div and visible() method returns only all divs that are visible as DOMNodeList.
  3. document.getElementsByClassName('FirstDiv').visible()
    the getElementsByClassName selects all elements having class FirstDiv and visible() method returns elements that are visible in list as DOMNodeList.
  4. document.getElementsByName('FirstDiv').visible()
    the getElementsByName selects all elements having name attribute "FirstDiv" and visible() method returns elements that are visible in list as DOMNodeList.
  5. document.querySelector('.FirstDiv').visible()
    the querySelector selects first div having class "FirstDiv" and visible() method return DOMNodeList having FirstDiv Element if visible otherwise empty list.
  6. document.querySelectorAll('.FirstDiv').visible()
    the querySelectorAll selects all elements having class FirstDiv and visible() method returns elements that are visible in list as DOMNodeList.



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