0 works

How to Detect a HTML Element Has a Class


dashboard+ Project

Posted by @starbucks #html #javascript

Code snippet:

var newForm = document.getElementById('new-form');

if ( newForm.getAttribute('class') === 'make-blue' ) {
        //  Do something
    }  
content_copyCopy to Clipboard

More details:

This code will perform a function if the HTML element possesses a class of the name "make-blue".


>> Browse more code snippets

more_vert