0 points

How to Detect a HTML Element Has a Class


dashboard

Posted by [deleted user] #html #javascript

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

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

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



>> Browse more code snippets

more_vert