Created
March 20, 2012 09:33
-
-
Save niwaringo/2133379 to your computer and use it in GitHub Desktop.
第2引数でjQueryオブジェクトを返すjQueryプラグイン
This file contains 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
/* | |
* 第2引数でjQueryオブジェクトを返すjQueryプラグイン | |
* $(selector).jeach(function(i, $e) { | |
* $e.text(); // $e -> jquery object | |
* this.tagName; // this -> dom elements | |
* ... | |
* }); | |
*/ | |
(function($) { | |
$.fn.jeach = function(callback) { | |
var jeach = function(object, callback) { | |
var i = 0, | |
length = object.length, | |
$object; | |
for ( ; i < length; ) { | |
$object = $(object[ i++ ]); | |
if (callback.call(object[ i ], i, $object) === false) { | |
break; | |
} | |
} | |
}; | |
jeach(this, callback); | |
return this; | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment