2

Is there a way to set css :focus using JS to all document without running a script for checking every element? Something like this, perhaps:

document.style.focus.backgroundColor = "#FF0000"; ?

I know this won't work, but is there any way to do something similar to this? If not, then how should I set the :focus globally for some specific style?

The only way I got is to run for all elements and only then attach styles for them, like this:

function TheFunction() {
    var findthemall = document.querySelectorAll("*");
    var i;
    for (i = 0; i < findthemall.length; i++) {
        findthemall[i].style.backgroundColor = "red";
        //etc, etc, etc...
    }
}

But I think it's a bad idea

franenos
  • 337
  • 2
  • 5
  • 14

0 Answers0