jQuery – get the first class only from a element March 2, 2023 by Tarik You need to split that into an array: console.log(jQuery('selector').attr('class').split(' ')[0]);