Home  >  Article  >  what is the focus

what is the focus

coldplay.xixi
coldplay.xixiOriginal
2021-01-13 16:59:2711172browse

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

Losing focus:

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

Syntax;

radioObject.blur()

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>

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!

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