How to get the class of a div on click [closed]

Try

$('.mainDiv div').click(function(){
    var className = $(this).attr('class');
});

Leave a Comment