Problems with getting class name with hyphens
I have class names like this:
- <div id="divFirst" class="firstname second-name"></div>
And also:
- <div id="divSecond" class="first-name second-name"></div>
This is the result:
- alert($('#divFirst').attr('class').split(' ')[1]);
Output ==> second-name
- alert($('#divSecond').attr('class').split(' ')[1]);
So if the first class name has hyphens then the second class name can't be found.
How come this happens?
Is there a way to get the second class name if the first one has hyphens?