One, the alternate color of the interlaced
Copy Code code as follows:
$ ("tr:odd"). CSS ("Background-color", "#eeeeee");
$ ("Tr:even"). CSS ("Background-color", "#ffffff");
Or a line to fix:
Copy Code code as follows:
$ ("Table tr:nth-child (Odd)"). CSS ("Background-color", "#eeeeee");
: Nth-child matches the nth child or parity element under its parent element
Second, the mouse through discoloration
Copy Code code as follows:
$ ("tr"). Live ({
Mouseover:function () {
$ (this). CSS ("Background-color", "#eeeeee");
},
Mouseout:function () {
$ (this). CSS ("Background-color", "#ffffff");
}
})
Or
Copy Code code as follows:
$ ("tr"). Bind ("MouseOver", function () {
$ (this). CSS ("Background-color", "#eeeeee");
})
$ ("tr"). Bind ("Mouseout", function () {
$ (this). CSS ("Background-color", "#ffffff");
})
Of course live () and bind () can bind multiple events or separate them at the same time.