Problems with getting class name with hyphens

Problems with getting class name with hyphens

I have class names like this:

  1. <div id="divFirst" class="firstname second-name"></div>

And also:
  1. <div id="divSecond" class="first-name second-name"></div>

This is the result:
  1. alert($('#divFirst').attr('class').split(' ')[1]);
Output ==> second-name
  1. alert($('#divSecond').attr('class').split(' ')[1]);
Output ==> Undefined

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?