Home > Common Problem > what is the focus

what is the focus

coldplay.xixi
Release: 2021-01-18 15:36:37
Original
11195 people have browsed it

The focus is the cursor. The focus is a small vertical line flashing in the page screen. The cursor can be obtained by clicking the mouse. The Tab key can switch the focus according to the set Tabindex. In JavaScriptongoing, it can be obtained through the [focus()] method. Focus, remove the focus through the [blur()] method.

The operating environment of this article: Acer S40-51, HBuilderX.3.0.5 version, Windows10 Home Chinese version

Related free learning recommendations: javascript video tutorial

Focus is the cursor, and the focus is the small vertical line that flashes on the page screen. Click the mouse to get the cursor, and the Tab key can switch focus according to the set Tabindex. In JavaScript, you can obtain the focus through the focus() method and remove the focus through the blur() method.

Get focus:

focus()The method is used to give focus to the checkbox.

Syntax:

checkboxObject.focus()
Copy after login

Losing focus:

blur()The method is used to remove the focus from the radio button.

Syntax;

radioObject.blur()
Copy after login

Example:

The following example can set or remove the focus on the radio button:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function setFocus() {
document.getElementById(&#39;check1&#39;).focus()
}
function loseFocus() {
document.getElementById(&#39;check1&#39;).blur()
}
</script>
</head>
<body>
<form>
<input type="text" id="check1" />
<br /><br />
<input type="button" onclick="setFocus()" value="获取焦点" />
<input type="button" onclick="loseFocus()" value="移开焦点" />
</form>
</body>
</html>
Copy after login

Rendering:

what is the focus

If you want to know more about programming learning, please pay attention to the php training column!

The above is the detailed content of what is the focus. 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