Open In App
Related Articles

HTML DOM Input Text blur() Method

Improve Article
Save Article
Like Article

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



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. 


<!DOCTYPE html>
        HTML DOM Input Text blur() Method
<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>
    <button onclick="myblur()">Get Focus!</button>
    <!-- script to remove focus to the text field-->
        function myblur() {
            var txt = document.getElementById("text_id").blur();


Supported Browsers:

  • Google Chrome 1
  • Mozilla Firefox 1
  • Edge 12
  • Opera
  • Safari 1
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 31 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials