Posts

Showing posts with the label innerHTML

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