Home >Web Front-end >Front-end Q&A >How to remove focus in jquery

How to remove focus in jquery

藏色散人
藏色散人Original
2023-02-17 10:20:462211browse

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()

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!

Statement:
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