Created
December 9, 2013 07:09
-
-
Save thirdj/7868442 to your computer and use it in GitHub Desktop.
how to get jquery first class
http://jsbin.com/aLERidIF/1/edit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var first = $('div').attr('class').replace(/^(\S*).*/, '$1'); | |
var second = $('div').attr('class').split(' ')[0]; | |
var third = $('div').attr('class').split(' ').shift(); | |
var ArrayData = $.map($('div').attr('class').split(' '), function(value){ | |
return value; | |
}); | |
var thirdFirst = $('div').attr('class').split(' ').pop(); | |
console.log('first :', first); // 처음 | |
console.log('second :', second); // 처음 | |
console.log('third :', third); // 처음 | |
console.log('ArrayData first :', ArrayData[0]); //처음 | |
console.log('ArrayData last :', ArrayData[ArrayData.length - 1]); // 마지막 | |
console.log('thirdFirst :', thirdFirst); // 마지막 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment