Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | DOM blur() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The DOM blur method is used to remove the keyboard focus from the current element and also give focus with the help of focus() method. We can apply the blur to any element and enable it by doing some operation. For example, we can blur to text-box by clicking a button. 

Syntax:

Object.blur()

Example: 

html




<html>
 
<head>
    <title>HTML DOM blur() Method</title>
</head>
 
<body style="text-align: center;">
    <h1 style="color:green;">
            GeeksforGeeks
        </h1>
 
    <h2>
            DOM blur Property
        </h2>
 
    <input type="text" id="txt" placeholder="Enter text here">
    <br>
    <br>
    <button type="button" onclick="inputFocus()">Focus</button>
    <button type="button" onclick="inputBlur()">Blur</button>
 
    <script>
        function inputFocus() {
            document.getElementById('txt').focus();
        }
 
        function inputBlur() {
            document.getElementById('txt').blur();
        }
    </script>
</body>
 
</html>

Output: 

Before clicking on focus button:

 blur 

After clicking on blur button:

 blur 

Supported Browsers: The browser supported by blur() method are listed below:

  • Google Chrome 1
  • Edge 12
  • Internet Explorer 5.5
  • Firefox 1.5
  • Opera 8
  • Safari 3

My Personal Notes arrow_drop_up
Last Updated : 13 Jul, 2022
Like Article
Save Article
Similar Reads
Related Tutorials