Jquery Stripe Odd/even Rows
quick JQuery question, I've got a products page that the user can filter. Each time a filter is applied/removed, a change event calls stripeTable() . I tried to implement the tableSolution 1:
The order of the psuedo-selectors matters.
// Computes "even" first, then "visible"
"#resultsTable > tbody > tr:even:visible"
// Compute "visible" first, then "even"
"#resultsTable > tbody > tr:visible:even"
Solution 2:
It's a much better idea to do it in CSS, something like:
#resultsTabletr:nth-of-type(even) {
background-color: #eee;
}
Solution 3:
CSS is the way to go here, although this doesn't answer the question it will advise future readers.
This below isn't IE8 compatible.
tabletr:nth-child(even) {
background-colour: red;
}
tabletr:nth-child(odd) {
background-colour: green;
}
The above is equivalent to below
//even
tabletr:nth-child(2n) {
background-colour: red;
}
//odd
tabletr:nth-child(2n + 1) {
background-colour: green;
}
quick JQuery question, I've got a products page that the user can filter. Each time a filter is applied/removed, a change event calls stripeTable() . I tried to implement the table
Solution 1:
The order of the psuedo-selectors matters.
// Computes "even" first, then "visible"
"#resultsTable > tbody > tr:even:visible"
// Compute "visible" first, then "even"
"#resultsTable > tbody > tr:visible:even"
Solution 2:
It's a much better idea to do it in CSS, something like:
#resultsTabletr:nth-of-type(even) {
background-color: #eee;
}
Solution 3:
CSS is the way to go here, although this doesn't answer the question it will advise future readers.
This below isn't IE8 compatible.
tabletr:nth-child(even) {
background-colour: red;
}
tabletr:nth-child(odd) {
background-colour: green;
}
The above is equivalent to below
//even
tabletr:nth-child(2n) {
background-colour: red;
}
//odd
tabletr:nth-child(2n + 1) {
background-colour: green;
}
Post a Comment for "Jquery Stripe Odd/even Rows"