Home > Web Front-end > JS Tutorial > js method to implement text box selection_javascript skills

js method to implement text box selection_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:57:37
Original
1588 people have browsed it

The example in this article describes the method of implementing text box selection in js. Share it with everyone for your reference. The details are as follows:

This javascript code can solve the problem that the text box gets focus, that is, the content of the text box is selected.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>select文件</title>
<script language="javascript" type="text/javascript">
function getFocus()
{
  document.getElementById("test").select();
}
</script>
</head>
<body>
<form id="f1">
<input type="text" id="test" name="test" value="你好嗎?" 
onfocus="getFocus();"/>
</form>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
js
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
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template