Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created July 17, 2011 23:20
Show Gist options
  • Save francescoagati/1088223 to your computer and use it in GitHub Desktop.
Save francescoagati/1088223 to your computer and use it in GitHub Desktop.
example of jquery.declare
$.fn.declare.add({
'row.alternate': function(opt) {
this.find("tr.odd")
.css("background-color",opt.odd_color)
.end()
.find("tr.even")
.css("background-color",opt.even_color);
}
});
$.fn.declare.add({
'row.hover':function(color_hover) {
this.hover(
function() {
var that=$(this);
that.data("old-bg",that.css("background-color"));
that.css("background-color",color_hover);
},
function() {
var that=$(this);
that.css("background-color", that.data("old-bg"));
}
)
}
});
$("table")
.declare('row.alternate',{
odd_color:'#ff0000',
even_color:'#00ff00'
})
.find("tr")
.declare("row.hover","#0000ff");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment