0

I'm trying to change the background color of input:cheked with JS, but I don't know how

  input:checked{
    background-color: #2196F3;
  }

I tried changing the bg color of the object with the class "input", but I need to change input:checked there is already an answer on Stack Overflow, but unfortunately all the solutions don't fit in my code because I'm working with many loops and chrome.runtime.onMessage

var v1 = document.createElement("input")
v1.style.backgroundColor = "red";
etog
  • 1
  • 1
  • It looks like you're trying to create the element rather than just change an existing element. If you want to change existing boxes' color... something like `document.querySelectorAll('input[type="checkbox"]:checked').forEach(e => e.style.backgroundColor = "red")` – Bman70 May 19 '23 at 00:26

0 Answers0