Horje
HTML DOM Input Text blur() Method

The Input Text blur() method in HTML DOM is used to pull or remove focus from the text field when the event occurs.  

Syntax:

textObject.blur()

Parameters: This method does not contain any parameter values.

Return Value: It does not return any value.

Example: Below program illustrates the use of the input text blur()  method in HTML DOM. 

HTML

<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Text blur() Method
    </title>
</head>
 
<body style="text-align:center;">
 
    <h1 style="color:green">GeeksforGeeks</h1>
 
    <strong>DOM Input Text blur() method</strong>
    <form id="myForm">
       <input type="text" id="text_id"
              name="userinput" autofocus>
    </form>
    <br>
    <button onclick="myblur()">Get Focus!</button>
     
    <!-- script to remove focus to the text field-->
    <script>
        function myblur() {
            var txt = document.getElementById("text_id").blur();
        }
    </script>
</body>
</html>                   

Output 

Supported Browsers:

  • Google Chrome 1
  • Mozilla Firefox 1
  • Edge 12
  • Opera
  • Safari 1



Reffered: https://www.geeksforgeeks.org


HTML

Related
HTML DOM Input URL focus() Method HTML DOM Input URL focus() Method
HTML DOM Marquee scrollDelay Property HTML DOM Marquee scrollDelay Property
HTML DOM Input Search focus() Method HTML DOM Input Search focus() Method
HTML DOM Input Text focus() Method HTML DOM Input Text focus() Method
What are Cell Padding &amp; Cell Spacing in HTML Table ? What are Cell Padding &amp; Cell Spacing in HTML Table ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
8