I have a form of two fields with I want that when I press a button both fields are placed in red background, until now I have this code but it does not work
function validacion(){
var valor = document.getElementsByTagName("input");
valor.setAttribute("style", "background-color: red;");
}
<form>
<input type="text" placeholder="texto" id="1" name="uno" class="caja"/>
<input type="text" placeholder="texto" id="2" name="dos" class="caja"/>
<input type="submit" value="aqui" onclick="return validacion()"/>
</form>
What happens is that I still need to be assigned to all the input so I use the getElementByTagName