Posts

Showing posts with the label cssSelector

javascript : .closest(cssSelector)

  javascript : .closest( cssSelector ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll select etc. Description : it search for closest parent element that matched with the selector. It traverse parentNode to parentNode untill matched with selector if no any parent element matched then it return empty array of nodeElementsList instead of null so nested statement not generate error due to null reference. Note : it start searching of selector from the element itself. That's mean if the element matches with the selector it return itself. Syntax: DOMElement.closest( cssSelector ) DOMNodeList.closest( cssSelector ) HTMLCollection.closest( cssSelector ) Usase: document.getElementById('firstDiv').closest( 'form' ) it search for firstDiv Element's parent form. document.getElementsByTagName('div').closest( 'form' ) the getElementsByTagName selects all div a...

javascript : .nextAll()

  javascript : .nextAll() Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll select etc. Description : return DOMNodeList of next all sibling elements of selected element. Note: if selector is DOM Elements List then first node element's next all sibling nodes return as DOMNodeList. Syntax: DOMElement.nextAll() DOMNodeList.nextAll() HTMLCollection.nextAll() Usase: document.getElementById('firstDiv').nextAll() it search element having id firstDive and return all elements next to it in same parent as DOMNodeList. document.getElementsByTagName('div').nextAll() the getElementsByTagName selects all div and nextAll() method return first div's next all sibling nodes as DOMNodeList document.getElementsByClassName('FirstDiv').nextAll() the getElementsByClassName selects all div having class "FirstDiv" and nextAll() method return first element's next all ...

javascript : .filter(cssSelector)

  javascript : DomElementList.filter( cssSelector ) Target: Applicable with any DOM element or elements List. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : it return DOMNodeList of element/elements List with filter of selector if matched. Note: use for removing elements from list that are not matched with selector. Syntax: DOMElement.filter( selector ) DOMNodeList.filter( selector ) HTMLCollection.filter( selector ) Usase: document.getElementById('firstDiv').filter( 'div' ) if element having id firstDiv is div then the DOMNodeList that returned has firstDiv element otherwise the list will empty. document.getElementsByTagName('div').filter( '.firstDiv' ) the getElementsByTagName selects all div and filter() method removes all dives that has not class name firstDiv and return DOMNodeList of all dives having class firstDiv. document.getElementsByClassName('FirstDiv').filter(...

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...

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: document.getElementById('firstDiv').visible() if the div having id firstDiv is visible then return DOMNodeList having firstDiv document.getElementsByTagName('div').visible() the getElementsByTagName selects all div and visible() method returns only all divs that are visible as DOMNodeList. document.getElementsByClassName('FirstDiv').visible() the getElementsByClassName selects all elements having class FirstDiv and visible() method returns elements that are visible in list as DOMNodeList. document.getElementsByName('FirstDiv').visible() the getElementsByName selects all elements having name attribute "FirstDiv" ...

javascript : .select(cssSelector)

  javascript : .select( cssSelector ) Target: Applicable with any DOM element or elements List. document getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll select find filter filterNot not visible nextAll prevAll next prev closest Description : It search selector element in the document/element/elements list itself or children and return all DOMNodeList that are matched with selector passed. Syntax: Document.select( selector ) DOMElement.select( selector ) DOMNodeList.select( selector ) HTMLCollection.select( selector ) Note : selector may be any css selector string or DomElement Usase: document.select('#firstDiv  input' ) it search input elements in firstDiv and return DOMNodeList of all input elements inside firstDiv. document.select(' .divExample ').select(' li ).select(' span ')  It find ".divExample" in document and then find "li" in result list and then find "span" i...