Posts

Showing posts with the label selector

javascript domElement .is(cssSelector|":visible"|domElement)

  javascript domElement .is( cssSelector|":visible"|domElement ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : return  true  if target element or first element of list is matched with selector other wise  false  . selector :  any css selector string ":visible" :  string for check is visible. Same as isVisible() method DomElement :  matched with element if both are same then return true other wise false. Syntax: DOMElement.is( selector ) DOMNodeList.is( selector ) HTMLCollection.is( selector ) Usase: document.getElementById('firstDiv').is( "div" ) it return true if firstDiv element is div other wise false document.getElementsByTagName('div').is( ".FirstDiv" ) the getElementsByTagName selects all div but is() method check for only first div and if it has class Firstdiv then return true else false. document.getElements...

javascript : DomElement .text()

  javascript : DomElement .text() Target: Applicable with any DOM element having attribute innerText. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll In case of DOM NodeList first Node Element is processed for get innerText. Description : get innerText of DOM element. Syntax: DOMElement.text() DOMNodeList.text() HTMLCollection.text() Usase: document.getElementById('firstDiv').text() it returns the innerText of firstDiv, that is " welcome " document.querySelector('#firstDiv').text() it returns the innerText of firstDiv, that is " welcome " document.querySelectorAll('div').text() it returns the innerHTML of first div's, that is " welcome " document.getElementsByTagName('div').text() it returns the innerHTML of first div's, that is " welcome " Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript obj...