I. line-by-line color change
$ ("Tr: odd" ).css ("background-color", "# eeeeee"); $ ("tr: even" ).css ("background-color ", "# ffffff ");
Or you can do it in one row:
$ ("Table tr: nth-child (odd)" ).css ("background-color", "# eeeeee ");
: Nth-child matches the nth child or parity element under its parent element.
2. Changing mouse color
$ ("Tr "). live ({mouseover: function({{}(this}.css ("background-color", "# eeeeee") ;}, mouseout: function({{}(this}.css ("background-color", "# ffffff ");}})
Or
$ ("Tr "). bind ("mouseover", function(commandid (this+.css ("background-color", "# eeeeee") ;}) $ ("tr "). bind ("mouseout", function(commandid (this0000.css ("background-color", "# ffffff ");})
Of course, both live () and bind () can be bound to multiple events or separated at the same time.
If the table is dynamically added, see http://blog.csdn.net/itmyhome1990/article/details/30245973