Método HTML DOM Textarea select ()
Definición y Uso
Método de selección () se utiliza para seleccionar el texto en el elemento.
gramática
textareaObject.select()
Soporte para el navegador
Todos los principales navegadores soportan método select ()
Ejemplos
Ejemplos
Los siguientes ejemplos pueden seleccionar texto en un cuadro de texto:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
document.getElementById("myTextarea").select();
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
<br>
<button type="button" onclick="displayResult()">选择文本框中的文本</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
document.getElementById("myTextarea").select();
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
<br>
<button type="button" onclick="displayResult()">选择文本框中的文本</button>
</body>
</html>
objeto textarea