Not sure if you can do this, but I want to select the first of two classes of an element with jQuery and return it's first class only.
<div class="module blue">
I want to return 'module'.
tried this:
var state = $('body').attr('class').first();
but none of that seems to work, thanks for any advice.
Try
var class = $('.module').attr('class');
var st = class.split(' ');
var firstClass = st[0];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With