Last active
August 29, 2015 14:08
-
-
Save z007/aaa608d7f2d494afe7d4 to your computer and use it in GitHub Desktop.
javascript 文本域 () 对输入框 显示内容 禁用 只读 textarea 动态改变 行列 默认输入法 文本框点击选中内容
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
文本域 值都在value中 | |
text | |
password | |
button | |
textare 在<textarea>value</textare> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> | |
</head> | |
<body> | |
<input type="text" o value="123" /><br /> | |
<input type="text" onfocus="this.select()" value="123" /><br /> | |
<input type="password" onfocus="this.select()" value="123" /><br /> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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>文本输入对象综合实例 动态改变textarea 行列 对input 显示 禁用 只读</title> | |
<script type="text/javascript"> | |
function myset(){ | |
if (document.myform.keyword.value == "123") { | |
document.myform.mytextarea.rows = document.myform.rowsnum.value; | |
document.myform.mytextarea.cols = document.myform.colsnum.value; | |
} | |
else { | |
alert("密码错误,不能设置文本域行列数!"); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<h2 align="center">文本输入对象</h2> | |
<form name="myform" action="" method="get"> | |
<label> | |
演示文本框:<input type="text" name="mytext" id="mytext" size="20" value="hello" /> | |
</label> | |
<p> | |
<input type="button" value="显示文本框内容" onclick="alert(document.myform.mytext.value);"/> | |
<!--是不是禁用 禁用 词句的意思 document.myform.mytext.disabled=!(document.myform.mytext.disabled);--> | |
<input type="button" value="“禁用”切换按钮" onclick="document.myform.mytext.disabled=!(document.myform.mytext.disabled);"/> | |
<input type="button" value="“只读”切换按钮" onclick="document.myform.mytext.readOnly=!(document.myform.mytext.readOnly );"/> | |
</p> | |
<p> | |
<hr> | |
<label> | |
演示文本域: | |
<br/> | |
<textarea name="mytextarea" id="mytextarea" rows="5" cols="40"> | |
这是一个文本域演示; | |
当你输入正确的密码后, | |
可以设置文本域的行数和列数 | |
</textarea> | |
</label> | |
</p> | |
<br> | |
<br> | |
行数:<input type="text" name="rowsnum" id="rowsnum" value="5" size="2" maxlength="2"> | |
列数:<input type="text" name="colsnum" id="colsnum" value="30" size="2" maxlength="2"> | |
<label> | |
设置密码: <input type="password" name="keyword" id="keyword" size="10"> | |
</label><input type="button" value="设置" onclick="myset()"> | |
</form> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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>默认输入法</title> | |
</head> | |
<body> | |
默认:<input type="text" /><br /> | |
中文:<input type="text" style="ime-mode:active" /><br /> | |
英文:<input type="text" style="ime-mode:inactive"/><br /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment