Posts

Showing posts with the label function

javascript : .off(eventName.NameSpace)

  javascript : .off( eventName ) .off( eventName.NameSpace ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : It remove  eventHandlerFunction  with element of  eventName.   It is the reverse of  on()  method. It is the easy way of  removeEventListener  method. eventName  : name of event that was registered with on() method. .NameSpace  : if event is register with NameSpace then for removing eventHandlerFunction NameSpace is used. Note: It clears the eventHandlerFunction from element register with on() method. Syntax: DOMElement.off( eventName ) DOMNodeList.off( eventName ) HTMLCollection.off( eventName ) Usase: document.getElementById('firstDiv').off( "click" ) It remove click eventHandlerFunction from element having id firstDiv. document.getElementsByTagName('div').off( "click" ) it remove click eventHandlerFunction fro...

javascript : domElementList .each( function )

  javascript : domElementList .each( fn ) Target: Applicable with any DOM element / elements list. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : executes the function in loop with each element in loop and return elements list. Note: loop function this represent individual element in list. Syntax: DOMElement.each(function(){  /*this element related statement*/  }) DOMNodeList.each(function(){  /*this element related statement*/  }) HTMLCollection.each(function(){  /*this element related statement*/  }) Usase: document.getElementById('firstDiv').each(function(){this.style.color='red';}) it executes the function passed and set firstDiv element's style color red. document.getElementsByTagName('div').each(function(){this.style.color='red';}) It loop for each div element and executes function for every div and set it's color style to red. document.getElementsByClassName('Fi...