From a table element, I would like to select all rows that have the class even
or the class odd
.
I tried the jQuery syntax:
report.css("table.data tr[class~=odd even]").each{|line| parse_line_item(line)}
but it threw an error, any help is appreciated, thanks.
Use two selectors: report.css("table.data tr.odd, table.data tr.even")
The ~=
operator in a CSS attribute selector checks that the value matches a space-delimited list of classes. For instance, tr[class~=odd]
would match <tr class="odd">
and <tr class="odd ball">
. However, in the specific case of the class
attribute, the better selector is simply tr.odd
.
If you use the ~=
operator with a space in the value (as in tr[class~="odd even"]
, the selector will never match anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With