English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Manera de acceder a las propiedades del objeto id en JavaScript (código de ejemplo)

Ejemplo real:

<!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=gb2312" />
<title>Documento sin título</title>
</head>
<body>
	<input type="text" value="Gané, gané un billón" id="mytext" />
	<script language="javascript">
		/*
		*	1、Obtener el valor de la propiedad value del id mytext
		*  2、Obtener el valor de la propiedad type del id mytext
		*/
		var txtElement = document.getElementById('mytext');
		//Podemos acceder a las propiedades a través de la propiedad del objeto.
		alert(txtElement.value);
		alert(txtElement.type);
	</script>
</body>
</html>

Aquí termina el contenido que el editor les ha traído sobre cómo acceder a las propiedades del objeto id en JavaScript (código de ejemplo). Esperamos que todos nos apoyen y alentemos a la tutoría de gritos ~

Te gustará