propiedad HTML DOM Textarea defaultValue
objeto textarea
Definición y Uso
defaultValue conjuntos de propiedades o devuelve el contenido inicial de la caja de texto.
Nota: El valor inicial del texto es un cuadro de texto situado <textarea> y </ textarea> etiquetas.Cuando el formulario se restablece, el cuadro de texto será restaurado a la totalidad del valor. Texto cambiar el valor de la propiedad va a cambiar el cuadro de texto que se muestra actualmente.
gramática
Estableciendo la propiedad defaultValue:
textareaObject.defaultValue="text"
Volver defaultValue atributos:
textareaObject.defaultValue
Consejo: defaultValue propiedad tiene ningún valor predeterminado.
值 | 描述 |
---|---|
text | 指定文本框的默认值 |
Soporte para el navegador
Todos los principales navegadores soportan la propiedad defaultValue
Ejemplos
Ejemplos
Los siguientes ejemplos sugieren el valor por defecto del cuadro de texto:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
alert(document.getElementById("myTextarea").defaultValue);
}
</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()
{
alert(document.getElementById("myTextarea").defaultValue);
}
</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