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>
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!