jQuery – get the first class only from a element

You need to split that into an array:

console.log(jQuery('selector').attr('class').split(' ')[0]);

Leave a Comment