Ask your JavaScript questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

I want to change all <input> with a name = "Player_Name" to (css) "background:blue;" JavaScript


I want to change all <input> with a name = "Player_Name" to (css) "background:blue;"

Answers (2)


mohitseth answers:

you can write the following CSS, you don't need javascript for it:

input[name="Player_Name"] {
background: blue;

If you really want to do in js, you can do following:

const inputs = document.querySelectorAll('input[name="Player_Name"]');

inputs.forEach((element) => { = 'blue';


Arnav Joy answers:

if you need js code you can try this

if ($(this).val() == 'Player_Name'){

where input_id is the same class added to input element