Using logical operators in querySelector CSS
P粉136356287
P粉136356287 2024-02-17 15:55:04
0
1
375

I'm trying to select all table cells with either colSpan or rowSpan greater than 1. I know you can do querySelectorAll('td[colspan="3"]') to select cells that meet narrower criteria. < /p>

But I need something like querySelectorAll('td[colspan>"1"]').

P粉136356287
P粉136356287

reply all(1)
P粉529245050

It is not possible to put conditional operators into querySelector. In your case, if you want to achieve it using only CSS selectors, then you can ignore the specific colspan conditions and select the rest using the :not operator.

td[colspan]:not(td[colspan = "1"]) {
   background : red;
 }

table, th, td {
  border: 1px solid black;
}
td[colspan]:not(td[colspan = "1"]) {
background : red;
}
Month Savings
January 0
February
Sum: 0
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template