您的位置:首页 > Web前端 > JQuery

jQuery表格选中行变色插件

2014-01-22 15:37 323 查看
$.fn.extend({
changecolor: function(options) {
var defaults = {
selectedColor: 'gainsboro' //选中后的颜色,默认淡灰色
};
options = $.extend(defaults, options);
return this.each(function() {
var $this = $(this);
var $trs = $this.find('tr').filter(function(index){return index >= 1;});
var selectedColor = options.selectedColor;
$trs.each(function(i, tr){
$(tr).bind('click', function(event){
$trs.each(function(i, n) {
if (n == tr) {
$(n).css('background-color', selectedColor);
} else {
$(n).css('background-color', 'white');
}
});
});
});
});
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: