Replying myself:

On 10/30/06, Choan C. Gálvez <[EMAIL PROTECTED]> wrote:
> 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:
> > [...]
> > 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()`.

Asuming that only browsers matched in `$.browser.safari` fails in
supporting `cellIndex`, this code could be used:

        (function($) {
                        var current;
                        $.fn.columnHoverClass = (function(className) {
                                $('td', this)
                                        .hover(function() {
                                                        var index = 
$.browser.safari ?
$(this.parentNode).children().index(this) : this.cellIndex;
                                                        current = 
$(this.parentNode.parentNode).find('tr >
td:nth-child('+ index +')').addClass(className);
                                        }, function() {
                                                        
current.removeClass(className);
                                        });
                                return this;
                        });
        })(jQuery);

Bye.
-- 
Choan
<http://choangalvez.nom.es/>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to