javascript : .find(cssSelector)
javascript : .find(cssSelector)
Target:
Applicable with any DOM element or elements List.
- getElementById
- getElementsByTagName
- getElementsByClassName
- getElementsByName
- querySelector
- querySelectorAll
- select
- etc.
Description :
it search selector in the element/elements list children and return all children DOMNodeList that are matched with selector passed.
Syntax:
DOMElement.find(selector)
DOMNodeList.find(selector)
HTMLCollection.find(selector)
Usase:
- document.getElementById('firstDiv').find('input')
it search input elements in firstDiv and return DOMNodeList of all input elements inside firstDiv. - document.getElementsByTagName('div').find('input')
the getElementsByTagName selects all div and find() method seaches input elements in all dives and return DOMNodeList of input elements. - document.getElementsByClassName('FirstDiv').find('input')
the getElementsByClassName selects all elements having class FirstDiv and find() method seaches input elements in all elements and returns DOMNodeList on input elements. - document.getElementsByName('FirstDiv').find('input')
the getElementsByName selects all elements having name attribute "FirstDiv" and find() method searches input elements in all elements and returns DOMNodeList of input elements. - document.querySelector('.FirstDiv').find('input')
the querySelector selects first div having class "FirstDiv" and find() method search input elements in firstDiv and return DOMNodeList of input elements. - document.querySelectorAll('.FirstDiv').find('input')
the querySelectorAll selects all elements having class FirstDiv and find() method search input elements in every elements and returns DOMNodeList of input elements.
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
Post a Comment