$("tr").hover(
function(){ $(this}.siblings().css("backgroundColor","#eee") },
function(){ $(this}.siblings().css("backgroundColor","white") }
);
*not tested
2006/10/30, Choan C. Gálvez <[EMAIL PROTECTED]>:
On 10/30/06, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote:
> > has anyone made this as (part of) a plugin?
> >
> > It would seem to be commonly requested - to help visulisation of a large
> > table.
>
> Try this:
> (function($) {
> var current;
> function findColumn(element) {
>
> }
> $.fn.columnHoverClass = (function(className) {
> $('td', this).hover(function() {
> var index = $(this).parent().children().index(this);
> current = $(this).parent().parent().find('tr > td:nth-child('+index+')');
> current.addClass(className);
> }, function() {
> current.removeClass(className);
> });
> return this;
> });
> })(jQuery);
>
> $('table').columnHoverClass('hover');
>
> Haven't tested it with big tables, yet.
I tried a similar approach wich resulted in a really bad performance.
There is a `cellIndex` property in every table cell. That coud be used
to improve performance (providing a workaround for browsers that don't
support it).
So... (workaround not included)
(function($) {
var current;
$.fn.columnHoverClass = (function(className) {
$('td', this).hover(function() {
current = $( this.parentNode.parentNode).find('tr >
td:nth-child('+this.cellIndex+')').addClass(className);
}, function() {
current.removeClass (className);
});
return this;
});
})(jQuery);
By the way, I _suspect_ that `$(this.parentNode.parentNode )` will
result in a better performance than `$(this).parent().parent()`.
--
Choan
<http://choangalvez.nom.es/>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
