Posts

Showing posts with the label element

javascript : Array .min

  javascript : Array  .min Target: Applicable with  Array  Data Type. Description : It traverse array and return minimum value. Note: If array is empty then return  undefined  . Syntax: []  .min Usase: [1,2,3,4,5,2,8,3,1].min It return  1 ['z','b','x','a','c'].min It return  'a' Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.  Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

javascript : Array .max

  javascript : Array  .max Target: Applicable with  Array  Data Type. Description : It traverse array and return maximum value. Note: If array is empty then return  undefined  . Syntax: []  .max Usase: [1,2,3,4,5,2,8,3,1].max It return  8 ['a','b','x','z','c'].max It return  'z' Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.  Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

javascript: Array .last

  javascript: Array  .last Target: Applicable with  Array  Data Type. Description : Return last element of array. Array[  lastIndex  ] element Note: If array is empty then return  undefined  . Syntax: []  .last return  Array[  lastIndex  ] element Usase: [1,2,3,4,5].last It return  5 [].last It return  undefined Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.  Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

javascript : Array .first

  javascript : Array  .first Target: Applicable with  Array  Data Type. Description : Return first element of array. Array[0] element Note: If array is empty then return  undefined  . Syntax: []  .first return  Array[0] element Usase: [1,2,3,4,5].first It return  1 [].first It return  undefined Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.  Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

javascript : domElement .remove()

  javascript : domElement .remove() Target: remove selected element from DOM. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : remove all element and it's children from DOM. Note: it return nothing. Syntax: DOMElement.remove() DOMNodeList.remove() HTMLCollection.remove() Usase: document.querySelector('container').remove() it remove container element from document document.querySelectorAll('ul').remove() it remove all UL elements from DOM. document.getElementsByClassName('output').remove() it remove all elements having class name output. Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.  Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

javascript domElement .append(domElement / htmlString)

  javascript domElement .append( domElement ) Target: add/create child element(s) in given element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll In case of DOM NodeList first Node Element is processed for append to child elements. Description : insert passed dom elements in selected dom element at the end of other child elements. Note: in case of string html is passed then new element is created and inserted. it return selected element for further processing. Syntax: DOMElement.append( domElement/htmlString ) DOMNodeList.append( domElement /htmlString ) HTMLCollection.append( domElement /htmlString ) Usase: document.querySelector('container').append("<span>Welcome</span>") it creates span element and insert it in container element document.querySelector('container').append(document.querySelectorAll("ul")) it insert all UL elements in container element. document.querySelector(...

javascript : domElement .isVisible()

  javascript : domElement .isVisible() Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : return  true  if target element or first element of list is visible other wise  false . Syntax: DOMElement.isVisible() DOMNodeList.isVisible() HTMLCollection.isVisible() Usase: document.getElementById('firstDiv').isVisible() it return true if firstDiv element is visible other wise false document.getElementsByTagName('div').isVisible() the getElementsByTagName selects all div but isVisible() method check for only first div and if it is visible then return true else false. document.getElementsByClassName('FirstDiv').isVisible() the getElementsByClassName selects all div having class "FirstDiv" but isVisible() method consider only first element and return true if it is visible other wise false. document.getElementsByName('FirstDiv').isVisible() the ...

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

javascript : domElement .fadeOut([duration],[callBack])

  javascript : domElement .fadeOut( [duration],[callBack] ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : Shows selected element/elements list with fade animation. duration : optional if not passed then default is 300ms. callBack :optional function executes when animation completes. Note: if callBack function is passed then after animation callback method will initiate. Syntax: DOMElement.fadeOut( [duration],[callBack] ) DOMNodeList.fadeOut( [duration],[callBack] ) HTMLCollection.fadeOut( [duration],[callBack] ) Usase: document.getElementById('firstDiv').fadeOut() it shows the div having id firstDiv with fade animation and return firstDiv element document.getElementsByTagName('div').fadeOut() the getElementsByTagName selects all div and fadeOut() method shows all divs with fade animation and return getElementsByTagName result for further processing you do...

javascript : DomElement .fadeIn([duration],[callBack])

  javascript : DomElement .fadeIn( [duration],[callBack] ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : hide selected element/elements list with fade animation. duration : optional if not passed then default is 300ms. callBack :optional function executes when animation completes. Note: if callBack function is passed then after animation callback method will initiate. Syntax: DOMElement.fadeIn( [duration],[callBack] ) DOMNodeList.fadeIn( [duration],[callBack] ) HTMLCollection.fadeIn( [duration],[callBack] ) Usase: document.getElementById('firstDiv').fadeIn() it hides the div having id firstDiv with fade animation and return firstDiv element document.getElementsByTagName('div').fadeIn() the getElementsByTagName selects all div and fadeIn() method hides all divs with fade animation and return getElementsByTagName result for further processing you do not nee...

javascript : domElement .hasClass( className )

  javascript : domElement .hasClass( className ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : return true/false if givent className exist with element classList. In case of elementsList it check first element's classList and return true/false. Syntax: DOMElement.hasClass(' className ') DOMNodeList.hasClass(' className ') HTMLCollection.hasClass(' className ') Usase: document.getElementById('firstDiv').hasClass(' myClass ') it check the div having id firstDiv classList contains className 'myClass' if contains then return true other wise false document.getElementsByTagName('div').hasClass(' myClass ') the getElementsByTagName selects all div and hasClass() method check class name 'myClass' in first div's classList for existance and return true/false document.getElementsByClassName('FirstDi...

javascript : domElement .removeClass(className)

  javascript : domElement .removeClass( className ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : remove givent className from element(s) classList if exists. Note: after removing class of element/elements list it return itself for further processing. Syntax: DOMElement.removeClass(' className ') DOMNodeList.removeClass(' className ') HTMLCollection.removeClass(' className ') Usase: document.getElementById('firstDiv').removeClass(' myClass ') it remove 'myClass' from the div having id firstDiv and return firstDiv element document.getElementsByTagName('div').removeClass(' myClass ') the getElementsByTagName selects all div and removeClass() method remove class name 'myClass' from all divs and return getElementsByTagName result for further processing you do not need to execute selector again. document....

javascript : domElement .addClass(className)

  javascript : domElement .addClass( className ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : add givent className to element(s) classList. Note: after adding class of element/elements list it return itself for further processing. Syntax: DOMElement.addClass(' className ') DOMNodeList.addClass(' className ') HTMLCollection.addClass(' className ') Usase: document.getElementById('firstDiv').addClass(' myClass ') it add 'myClass' to the div having id firstDiv and return firstDiv element document.getElementsByTagName('div').addClass(' myClass ') the getElementsByTagName selects all div and addClass() method add class name 'myClass' to all divs and return getElementsByTagName result for further processing you do not need to execute selector again. document.getElementsByClassName('FirstDiv').addCl...

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