Utility function to determine if the element has a classname class - Node.js CSS

Node.js examples for CSS:Class

Description

Utility function to determine if the element has a classname class

Demo Code

/**/*from   ww w  .  ja v a 2 s. co  m*/
 * Utility function to determine if the ele element has a classname class
 * @param ele
 * @param classname
 * @return - true if ele has classname
 */
function hasClass(ele, classname) {
  if ((' '+ele.className+' ').indexOf(' '+classname+' ') > -1) {
    return true;
  } else {
    return false;
  }
}

Related Tutorials