search

Home  >  Q&A  >  body text

Using logical operators in querySelector CSS

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粉136356287P粉136356287273 days ago333

reply all(1)I'll reply

  • P粉529245050

    P粉5292450502024-02-18 00:22:37

    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

    reply
    0
  • Cancelreply