Last active
February 17, 2016 03:25
-
-
Save think49/c382098fedd9ae7c6661 to your computer and use it in GitHub Desktop.
jquery.get-classlist.js: jQuery オブジェクトの最初のインデックスとなる要素ノードから classList (HTML5規定) を得る jQuery plugin
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
/** | |
* jquery.get-classlist.js | |
* get a classList of first index's jQuery object. | |
* | |
* @version 1.0 | |
* @author think49 | |
* @url https://gist.github.com/think49/c382098fedd9ae7c6661 | |
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License) | |
*/ | |
jQuery.fn.getClassList = function getClassList () { | |
var element; | |
if (this.length < 1) { | |
return []; | |
} | |
element = this[0]; | |
return 'classList' in element ? element.classList : element.className.split(/\s+/); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment