Example:
Here we have <p class="tab1 current"></p>
<p class="tab1 current"></p>
How can I get only the first class?
var GetFirstClass = $('p').attr('class').filter(':first'); ??
var GetFirstClass = $('p').attr('class').filter(':first');
Any help much appreciated.
Use JavaScript's split function:
split
$('p').attr('class').split(' ')[0]
Demo
You can split the string based on the space.
$('<div class="a b"/>').attr('class').split(' ')[0]