How to remove focus in jquery

藏色散人
Release: 2023-02-17 10:20:46
Original
2165 people have browsed it

Jquery method to remove focus: 1. Get focus through "document.getElementById('test').focus()"; 2. Use "document.getElementById('test').blur();" Method to remove focus.

How to remove focus in jquery

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()
Copy after login

2. Remove focus:

document.getElementById('test').blur();
Copy after login

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()
Copy after login

Add a function to the blur event:

$(selector).blur(function)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template