Created
March 25, 2014 05:43
-
-
Save nisar1/9755860 to your computer and use it in GitHub Desktop.
jquery ui table design
This file contains hidden or 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
//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