4
I created a formula in which when clicking on a field its bottom edge changes color, and I used an onblur() so that the color returns to normal when clicking outside. However, I wanted this function to function individually in each input. Let each one change color when selected without having to write the same function several times for each id. How can I do this?
<form>
<input type="number" placeholder="idade" id="a" onclick="azul()" onblur="nada()">
<input type="text" placeholder="nome" id="b" onclick="azul()" onblur="nada()">
(...)
</form>
<script>
function azul(){
var a = document.getElementById("a");
a.style.borderBottomColor = "#4976d0";
}
function nada(){
var a = document.getElementById("a");
a.style.borderBottomColor = "transparent";
}
</script>
Create a Generic function by passing 2 parameters, one that is id and the other the color you want
– Luan Brito