$.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');
}
});
});
});
});
}
});
jQuery表格选中行变色插件
最新推荐文章于 2021-10-27 18:05:33 发布
