Hi,
Why is it that this code:
$('#tbl tr:odd').css('background-color', '#f6f6f6');
$('#tbl tr:even').css('background-color', '#cccccc');
works fine outside of the plugin in all browsers. While the same code:
$('tr:odd', $this).css('background-color', options.tr_odd_bgcolor);
$('tr:even', $this).css('background-color', options.tr_even_bgcolor);
doesn't color rows at all in any version of IE where $this
refers to table specified in wrapped set and options.tr_odd_bgcolor
refers to color for example green
.
The plugin styling does apply in all browsers except for IE.
Here is the plugin code for your reference:
(function($){
$.fn.styleTable = function(settings){
var opts = $.extend({}, $.fn.styleTable.defaults, settings);
return this.each(function(settings){
var options = $.extend({}, opts, $(this).data());
var $this = $(this);
$('tr:odd', $this).css('background-color', options.tr_odd_bgcolor);
$('tr:even', $this).css('background-color', options.tr_even_bgcolor);
});
}
$.fn.styleTable.defaults = {
tr_odd_bgcolor: '#f6f6f6',
tr_even_bgcolor: '#fff'
}
})(jQuery);