javascript .prevAll()
javascript .prevAll()
Target:
Applicable with any DOM element.
- getElementById
- getElementsByTagName
- getElementsByClassName
- getElementsByName
- querySelector
- querySelectorAll
- select
- etc.
Description :
return DOMNodeList of prev all sibling elements of selected element.
Note: if selector is DOM Elements List then first node element's previous all sibling nodes return as DOMNodeList.
Syntax:
DOMElement.prevAll()
DOMNodeList.prevAll()
HTMLCollection.prevAll()
Usase:
- document.getElementById('firstDiv').prevAll()
it search element having id firstDive and return all elements previous to it in same parent as DOMNodeList. - document.getElementsByTagName('div').prevAll()
the getElementsByTagName selects all div and prevAll() method return first div's previous all sibling nodes as DOMNodeList - document.getElementsByClassName('FirstDiv').prevAll()
the getElementsByClassName selects all div having class "FirstDiv" and prevAll() method return first element's previous all sibling nodes as DOMNodeList. - document.getElementsByName('FirstDiv').prevAll()
the getElementsByName selects all elements having name attribute "FirstDiv" and prevAll() method return first element's previous all sibling nodes as DOMNodeList. - document.querySelector('.FirstDiv').prevAll()
the querySelector selects first div having class "FirstDiv" and prevAll() method return previous all elements as DOMNodeList. - document.querySelectorAll('.FirstDiv').prevAll()
the querySelectorAll selects all div having class "FirstDiv" and prevAll() method return first element's previous all sibling nodes 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
Post a Comment