Posts

Showing posts with the label getElementByTagName

javascript : dom Elements .toggle()

  javascript : DomElements.toggle() Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : toggle element display style none. Note: after setting the style display of element/elements list it return itself for further processing. Syntax: DOMElement.toggle() DOMNodeList.toggle() HTMLCollection.toggle() Usase: document.getElementById('firstDiv').toggle() it hide/show the div having id firstDiv and return firstDiv element document.getElementsByTagName('div').toggle() the getElementsByTagName selects all div and toggle() method hide/show all divs and return getElementsByTagName result for further processing you do not need to execute selector again. document.getElementsByClassName('FirstDiv').toggle() the getElementsByClassName selects all div having class "FirstDiv" and toggle() method hide/show all divs and return getElementsByClassName result for ...

javascript : dom elements .show()

  javascript : DomElements.show() Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : It remove dom element inline display style if currently "none". if after that applicable style is "none" then sets inline style to "block" Note: after setting the style display of element/elements list it return itself according to selector for further processing. Syntax: DOMElement.show() DOMNodeList.show() HTMLCollection.show() Usase: document.getElementById('firstDiv').show() it shows the div having id firstDiv and return firstDiv element document.getElementsByTagName('div').show() the getElementsByTagName selects all div and show() method shows all divs and return getElementsByTagName result for further processing you do not need to execute selector again. document.getElementsByClassName('FirstDiv').show() the getElementsByClassName se...

javascript : Dom Elements .hide()

  javascript : DomElements .hide() Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : set dom element style display none. Note: after setting the style display of element/elements list it return itself for further processing. Syntax: DOMElement.hide() DOMNodeList.hide() HTMLCollection.hide() Usase: document.getElementById('firstDiv').hide() it hides the div having id firstDiv and return firstDiv element document.getElementsByTagName('div').hide() the getElementsByTagName selects all div and hide() method hides all divs and return getElementsByTagName result for further processing you do not need to execute selector again. document.getElementsByClassName('FirstDiv').hide() the getElementsByClassName selects all div having class "FirstDiv" and hide() method hides all divs and return getElementsByClassName result for further processing you do no...

javascript : DomElement .html(html)

  javascript : DomElement .html( html ) Target: Applicable with any DOM element having attribute innerHTML. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll In case of DOM NodeList first Node Element is processed for get/set. Description : get/set innerHTML of DOM element. if html is passed then it set the innerHTML and return element itself, otherwise return innerHTML of element. Note: after setting the innerHTML of element it return the element itself. Syntax: DOMElement.html( 'html' ) DOMNodeList.html( 'html' ) HTMLCollection.html( 'html' ) Usase: document.getElementById('firstDiv').html("welcome") it sets the innerHTML of div having id firstDiv with html " welcome " and return firstDiv element document.querySelector('#firstDiv').html("welcome") it sets the innerHTML of div having id firstDiv with innerHTML " welcome " and return firstDiv element...

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

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 : .prev()

  javascript : domElement .prev() Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : return previous sibling element of selected element other wise empty nodeList. Note: if selector is DOM Elements List then first node element's previous sibling node return. Syntax: DOMElement.prev() DOMNodeList.prev() HTMLCollection.prev() Usase: document.getElementById('firstDiv').prev() if firstDive element's previous sibling node exists return it. document.getElementsByTagName('div').prev() the getElementsByTagName selects all div and prev() method return previous sibling node if exists document.getElementsByClassName('FirstDiv').prev() the getElementsByClassName selects all div having class "FirstDiv" and prev() method return first element's previous sibling node if exists. document.getElementsByName('FirstDiv').prev() the getElements...

javascript : .next()

javascript : domElement .next() Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll select etc. Description : return next sibling element of selected element other wise empty nodesList. Note: if selector is DOM Elements List then first node element's next sibling node return. Syntax: DOMElement.next() DOMNodeList.next() HTMLCollection.next() Usase: document.getElementById('firstDiv').next() if firstDive element's next sibling node exists return it. document.getElementsByTagName('div').next() the getElementsByTagName selects all div and next() method return next sibling node if exists document.getElementsByClassName('FirstDiv').next() the getElementsByClassName selects all div having class "FirstDiv" and next() method return first element's next sibling node if exists. document.getElementsByName('FirstDiv').next() the getElementsByName se...

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

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

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