Example:
HTML
First name: <input type="text" id="fname" onfocus="myFunction(this.id)"><br>
Last name: <input type="text" id="lname" onfocus="myFunction(this.id)">
<script>
function myFunction(x) {
document.getElementById(x).style.background = "yellow";
}
</script>
How to Execute a JavaScript when an input field gets focus | HTML Attribute |
Type: | Html |
Category: | Web Tutorial |
Sub Category: | HTML Attribute |
Uploaded by: | Admin |