I really like this click-to-select effect. 

> var what = $(this).get(0).className;

That is the same as this.className, but a lot more expensive since it has to
build a jQuery object.

> if( what == "alt over" || what == "over" ) 

You're assuming that the class names will always be in a particular order,
but className could be "over alt", or "over down alt" as well. It looks like
you're trying to check for the over class with/without the down class, and
the alt class just gets in the way? If so then try this--tested in IE and
FF:

function dynamicTable() {
  $(".content_table tr")
    .hover(
      function() {$(this).addClass("over");},
      function() {$(this).removeClass("over");}
    )
    .mousedown(function() {
      var e = $(this);
      e[e.is(".over:not(.down)")?"addClass":"removeClass"]("down");
    })
    .select(":even").addClass("alt");
}

Still, I'm not quite sure why you wanted to check for .over in the
click...how would you get to the click function unless the mouse was over
the element? If it's not necessary to do that check, you can reduce the
mousedown to a single line:

     $(this).toggleClass("down");

Seems like adding/removing a class on hover is very common, it might be
worth having a .hoverClass("classname") that hid the add/removing one level
down. That way you'd be able to say this:

function dynamicTable() {
  $(".content_table tr")
     .hoverClass("over")
     .mousedown(function() {$(this).toggleClass("down"); }).
     .select(":even").addClass("alt");
}

Man, if anyone ever tries to measure jQuery productivity in lines of code we
are *totally* screwed. ;-)



_______________________________________________
jQuery mailing list
[EMAIL PROTECTED]
http://jquery.com/discuss/

Reply via email to