Answer: Here in this we have a textbox with onfocus event.When we focus(means when we place the cursor)on the textbox ,GetFocus executes that recieves the id of the textbox In this function, we are finding the texbox (using its id passed in to function) and setting its background color to “blue”.
example:
Enter your name: <input type="text" name="txtName" id="txtName" onfocus="GotFocus(this.id)" />
<input type="button" id="btn" name="btn" value="Submit" />
<script type="text/javascript">
function GotFocus(id) {
document.getElementById(id).style.background = "#c0c0c0";
}
</script>
Asked In: While Learning |
Alert Moderator