Example:
Here we have <p class="tab1 current"></p>
How can I get only the first class?
var GetFirstClass = $('p').attr('class').filter(':first');
??
Any help much appreciated.
Use JavaScript's split
function:
$('p').attr('class').split(' ')[0]
Demo
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