javascript .not(cssSelector)
javascript : DomElementList.not(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.not(selector)
DOMNodeList.not(selector)
HTMLCollection.not(selector)
Usase:
- document.getElementById('firstDiv').not('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').not('.firstDiv')
the getElementsByTagName selects all div and not() method removes all dives that has class name firstDiv and return DOMNodeList of all dives having not class firstDiv. - document.getElementsByClassName('FirstDiv').not('div')
the getElementsByClassName selects all elements having class FirstDiv and not() method remove all elements that are div and returns DOMNodeList of elements having class firstDiv but not div. - document.getElementsByName('FirstDiv').not('div')
the getElementsByName selects all elements having name attribute "FirstDiv" and not() method remove all elements that are div and returns DOMNodeList of elements having name attribute firstDiv but not div. - document.querySelector('.FirstDiv').not('div')
the querySelector selects element having class "FirstDiv" and not() 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').not('div')
the querySelectorAll selects all elements having class FirstDiv and not() 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