<!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>文本框的事件与方法</title>
<script language="JavaScript"
type="text/javascript">
function txt1select()
{
document.form1.text1.select();
}
function txt2focus()
{
document.form1.text2.focus();
}
</script>
</head>
<body>
<form name="form1">
<p>
<input type="text" name="wbk1" id="wbk1"
value="abc选中试试" οnselect="alert('文本被选中');"/>
<br /><br />
<input type="text" name="wbk2" id="wbk2"
value="获取焦点" οnfοcus="alert('获得了焦点');"/><br
/><br />
<input type="text" name="wbk3" id="wbk3"
value="失去焦点" οnblur="alert('失去焦点');"/><br />
<br />
<input type="text" name="wbk4" id="wbk4"
value="文本框改变" οnchange="alert('文本内容已经改
变');"/>
</p>
<p>文本框0: <input name="text0" type="text"
id="text0" value="" /></p>
<p>文本框1: <input name="text1" type="text"
id="text1" value="ABCD" /></p>
<p>文本框2: <input name="text2" type="text"
id="text2" value="cccc" /></p>
<p>文本框3: <input name="text3" type="text"
id="text3" value="本文本框内容无法更改"
readonly="readonly" /></p>
<p>
<input name="btn1" type="button" value="文本框1内
容被选中" οnclick="txt1select()" />
<input name="btn2" type="button" id="btn2"
value="文本框2获得焦点" οnclick="txt2focus()" />
</p>
</form>
</body>
</html>