Created
August 5, 2011 23:03
-
-
Save blockworks/1128734 to your computer and use it in GitHub Desktop.
yuga.jsを改良。tableの列(縦)側にもクラスを振る
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
//該当部分だけのコードです。ソースを見て、必要な箇所だけコピペで差し替えてください。 | |
//奇数、偶数を自動追加 | |
stripe: function(options) { | |
var c = jQuery.extend({ | |
oddClass:'odd', | |
evenClass:'even', | |
rowoddClass:'rowodd', | |
rowevenClass:'roweven' | |
}, options); | |
jQuery('ul, ol').each(function(){ | |
//JSでは0から数えるのでevenとaddを逆に指定 | |
jQuery(this).children('li:odd').addClass(c.evenClass); | |
jQuery(this).children('li:even').addClass(c.oddClass); | |
}); | |
jQuery('table, tbody').each(function(){ | |
jQuery(this).children('tr:odd').addClass(c.evenClass); | |
jQuery(this).children('tr:even').addClass(c.oddClass); | |
}); | |
//テーブルの列(縦)を縞模様にする | |
jQuery('table tr').each(function(){ | |
jQuery(this).children('th:odd').addClass(c.rowevenClass); | |
jQuery(this).children('th:even').addClass(c.rowoddClass); | |
jQuery(this).children('td:odd').addClass(c.rowevenClass); | |
jQuery(this).children('td:even').addClass(c.rowoddClass); | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment