Created
October 15, 2010 03:08
-
-
Save nenjiru/627538 to your computer and use it in GitHub Desktop.
ストライプテーブル jQuery Plugin
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
//////////////////////////////////////////////////////////////////////////////// | |
// Add a classname to the alternate - jQuery Plugin | |
// 交互にクラス名を付与してストライプなテーブルを作成 | |
// | |
// Copyright 2010, Minoru Nakanow | |
// Licensed under the MIT licenses. | |
// http://www.opensource.org/licenses/mit-license.html | |
// | |
// Usage: | |
// $("table").stripeTable(); | |
// | |
//////////////////////////////////////////////////////////////////////////////// | |
(function($) { | |
//-------------------------------------------------------------------------- | |
// jQuery extend | |
//-------------------------------------------------------------------------- | |
jQuery.fn.extend({ | |
/** | |
* Stripe Table | |
* | |
* @param {String|Boolean} row 偶数行へのクラス名、falseでスキップ (初期値: "even") | |
* @param {String|Boolean} col 偶数列へのクラス名、falseでスキップ (初期値: "even") | |
* @return {jQuery} | |
*/ | |
stripeTable: function(row, col) { | |
row = (row == undefined) ? "even" : row; | |
col = (col == undefined) ? "even" : col; | |
return this.each(function() { | |
$(this).find("tr:nth-child(even)").addClass(row) | |
.end().find("td:nth-child(even)").addClass(col); | |
}); | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment