Created
July 17, 2011 23:20
-
-
Save francescoagati/1088223 to your computer and use it in GitHub Desktop.
example of jquery.declare
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
$.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