Archive for jQuery
Javascript / jQuery get first class name of element
February 16th, 2012 • 2 comments javascript, jQuery, snippets
Need to get the first class name of an element? Simple! Imagine having a link with 3 class names
<a id="myelement" href="http://google.com" class="class1 class2 class3">Go to google</a>
$('a#myelement').attr('class').split(' ')[0]
Will result in: class1