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

js method to implement text box selection_javascript skills

WBOY
Release: 2016-05-16 15:57:37
Original
1566 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
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