javascripthtmlcssuser-interfacequeryselector

Can HTML inputs with an indeterminate state set be found via querySelector?


Is there a method to enable this? Or is it managed beyond the reach of CSS?

I'm thinking there's no way based on my research so far and the fact it's not rendered as an attribute on the input.


Solution

  • There is an :indeterminate pseudo class.

    const inp = document.querySelector("input");
    inp.indeterminate = true;
    :indeterminate { outline: 5px solid red; }
    <input type="checkbox">
    <input type="checkbox">