javascript : .filterNot(cssSelector)
javascript : DomElementList.filterNot(cssSelector)
Target:
Applicable with any DOM element or elements List.
- getElementById
- getElementsByTagName
- getElementsByClassName
- getElementsByName
- querySelector
- querySelectorAll
- select
- etc.
Description :
it return DOMNodeList of element/elements List with filter of selector that are not matched.
Note: use for removing elements from list that are matched with selector.
Syntax:
DOMElement.filterNot(selector)
DOMNodeList.filterNot(selector)
HTMLCollection.filterNot(selector)
Usase:
- document.getElementById('firstDiv').filterNot('div')
if element having id firstDiv is not div then the DOMNodeList that returned has firstDiv element otherwise the list will empty. - document.getElementsByTagName('div').filterNot('.firstDiv')
the getElementsByTagName selects all div and filterNot() method removes all dives that has class name firstDiv and return DOMNodeList of all dives having not class firstDiv. - document.getElementsByClassName('FirstDiv').filterNot('div')
the getElementsByClassName selects all elements having class FirstDiv and filterNot() method remove all elements that are div and returns DOMNodeList of elements having class firstDiv but not div. - document.getElementsByName('FirstDiv').filterNot('div')
the getElementsByName selects all elements having name attribute "FirstDiv" and filterNot() method remove all elements that are div and returns DOMNodeList of elements having name attribute firstDiv but not div. - document.querySelector('.FirstDiv').filterNot('div')
the querySelector selects element having class "FirstDiv" and filterNot() method check that the element is div or not. if element is not div then it return DOMNodeList with this element other wise empty DOMNodeList - document.querySelectorAll('.FirstDiv').filterNot('div')
the querySelectorAll selects all elements having class FirstDiv and filterNot() method remove divs and return DOMNodeList of all elements that have class firtDiv but not div.
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