Utiliser la fonction onFocus

posted in: html | 0

Lorsque la fonction est activée, la couleur arrière du champ de l’imput change.

Prénom :
Nom :

Le code expliqué

<p>Lorsque la fonction est activée, la couleur arrière du champ de l’imput change.</p>
Prénom : <input type= »text » id= »fname » onfocus= »myFunction(this.id) »><br>
Nom : <input type= »text » id= »lname » onfocus= »myFunction(this.id) »>

<script>
function myFunction(x) {
document.getElementById(x).style.background = « yellow »;
}
</script>

logowebmaster1