input对象

input对象

一个<input>标记,就是一个input对象。


input对象的属性(以type=text为例)

  • name:表单元素的名称。

  • value:表单元素的值,用户输入的内容,可以通过该属性来获取。

  • size:表单的长度。

  • maxlength:表单元素的最大长度(最多可输的字符数)。

  • disabled:禁用属性。

  • readonly:只读属性。


input对象的方法

  • focus():获得焦点的方法(定位光标)。

  • blur():失去焦点的方法(移走光标)。

  • select():选中文本的方法。


input对象的事件

  • onfocus:当获得焦点时

  • onblur:当失去焦点时

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>php.cn</title>
<script>
</script>
</head>
<body>
<form name="form1" method="post" action="login.php">
用户名:<input type="text" name="username" onfocus="this.value='focus';this.select()" onblur="this.value='blur'" />
密码:<input type="password" name="userpwd" />
<input type="submit" value="提交表单" />
</form>
</body>
</html>
继续学习
||
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8" /> <title>php.cn</title> <script> </script> </head> <body> <form name="form1" method="post" action="login.php"> 用户名:<input type="text" name="username" onfocus="this.value='focus';this.select()" onblur="this.value='blur'" /> 密码:<input type="password" name="userpwd" /> <input type="submit" value="提交表单" /> </form> </body> </html>
提交重置代码
章节
笔记
提问
课件
反馈
捐赠

javascript初级教程

高并发千万级数据库系统解决方案
  • 推荐课程
  • 评论
  • 问答
  • 笔记
  • 课件下载