Jquery method to remove focus: 1. Get focus through "document.getElementById('test').focus()"; 2. Use "document.getElementById('test').blur();" Method to remove focus.
The operating environment of this tutorial: Windows 10 system, jquery3.2.1 version, Dell G3 computer.
How to remove focus in jquery?
js method to make the original element gain focus and remove focus
1. Get focus:
document.getElementById('test').focus()
2. Remove focus:
document.getElementById('test').blur();
Related introduction:
The blur event occurs when an element loses focus.
blur() method triggers the blur event, or specifies a function to run when the blur event occurs.
Tip: This method is often used together with the focus() method.
Syntax
Trigger the blur event for the selected element:
$(selector).blur()
Add a function to the blur event:
$(selector).blur(function)
Parameter function is optional. Specifies the function to run when the blur event occurs.
Recommended learning: "jQuery Video Tutorial"
The above is the detailed content of How to remove focus in jquery. For more information, please follow other related articles on the PHP Chinese website!