Prev Demo
JavaScript
>
How To Execute A Function When An Element Loses Focus In Javascript?
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Onblur</h1> Enter your name: <input type="text" name="txtName" id="txtName" onblur="CallFunction(this.id)" /> <input type="button" id="btn" name="btn" value="Submit" /> <script> function CallFunction(id) { document.getElementById(id).style.background = "#c0c0c0"; } </script> <p><strong>Note: </strong>Click the button after entering the text in text box, you can find onblur event.</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output