Skip to content

Instantly share code, notes, and snippets.

@nisar1
Created March 25, 2014 05:43
Show Gist options
  • Save nisar1/9755860 to your computer and use it in GitHub Desktop.
Save nisar1/9755860 to your computer and use it in GitHub Desktop.
jquery ui table design
//css
jtable td{font-weight: bold;}
//js
$().ready(function(){
$(".jtable th").each(function(){
$(this).addClass("ui-state-default");
});
$(".jtable td").each(function(){
$(this).addClass("ui-widget-content");
});
$(".jtable tr").hover(
function()
{
$(this).children("td").addClass("ui-state-hover");
},
function()
{
$(this).children("td").removeClass("ui-state-hover");
}
);
$(".jtable tr").click(function(){
$(this).children("td").toggleClass("ui-state-highlight");
});
});
//other method
(function ($) {
$.fn.styleTable = function (options) {
var defaults = {
css: 'ui-styled-table'
};
options = $.extend(defaults, options);
return this.each(function () {
$this = $(this);
$this.addClass(options.css);
$this.on('mouseover mouseout', 'tbody tr', function (event) {
$(this).children().toggleClass("ui-state-hover",
event.type == 'mouseover');
});
$this.find("th").addClass("ui-state-default");
$this.find("td").addClass("ui-widget-content");
$this.find("tr:last-child").addClass("last-child");
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment