Toggles the element's display style - Node.js DOM

Node.js examples for DOM:Element

Description

Toggles the element's display style

Demo Code


/**//  w w w. j  ava 2s .c o  m
 * Toggles the ele element's display style
 * @param ele
 */
function toggleDisplay(ele) {
  if (ele.style.display=='block' || ele.style.display.trim()=='') {
    ele.style.display='none';
  } else {
    ele.style.display='block'
  }
}

Related Tutorials