按钮常用属性
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=
, initial-scale=1.0"
/>
<title>按钮常用属性</title>
</head>
<body>
<form action="login.php" id="rege">
<section>
<label for="username">用户名:</label>
<input
type="username"
id="username"
name="username"
placeholder="不少于6位"
autofocus
required
/>
</section>
<section>
<label for="password">密码:</label>
<input
type="password"
id="password"
name="password"
placeholder="不少于6位"
required
/>
</section>
<section>
<button form="rege" formmethod="GET" formtarget="_blank">提交</button>
</section>
</form>
</body>
</html>
- 显示按钮界面
![](https://img.php.cn/upload/image/846/370/500/1586078946559347.png)
- 显示按钮效果
![](https://img.php.cn/upload/image/609/363/136/1586078959761529.png)
-
下拉列表常用属性和事件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>下拉列表的常用属性</title>
</head>
<body>
<form action="">
<select
name="lang"
onclick="alert(this.value)"
onchange="alert(this.value)"
multiple
>
<optgroup label="科目">
<option value="ch">语文</option>
<option value="ms">数学</option>
<option value="en" selected>英语</option>
</optgroup>
<optgroup label="教师">
<option value="zs">张三</option>
<option value="ls">李四</option>
<option value="we">王二</option>
</optgroup>
</select>
</form>
</body>
</html>
- 显示下拉列表
![](https://img.php.cn/upload/image/306/498/917/1586081378799960.png)
- 显示下拉列表多选(multiple)
![](https://img.php.cn/upload/image/512/383/187/1586081409251882.png)
- 显示下拉列表预设选项(selected)
![](https://img.php.cn/upload/image/483/519/770/1586081458609459.png)
- 显示下拉列表选项改变时显示选项(onchange)
![](https://img.php.cn/upload/image/267/241/194/1586081720685028.png)
- 显示下拉列表点击选项时显示选项(onclick)
![](https://img.php.cn/upload/image/854/191/806/1586081758280385.png)
文本域常用属性和事件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>文本域的属性</title>
</head>
<body>
<form action="login.php" method="POST" target="_blank">
<textarea
name="rtext"
placeholder="说明你要写的文字,不超过50字"
minlength="5"
maxlength="50"
cols="30"
rows="10"
onchange="alert('内容被修改!')"
onselect="this.style.color='green'"
>
请说明你要说的内容……</textarea
>
<button type="submit">提交</button>
</form>
</body>
</html>
- 显示文本域
![](https://img.php.cn/upload/image/872/608/835/1586083724554904.png)
![](https://img.php.cn/upload/image/856/366/365/1586083743625884.png)
- 显示文本域改变内容时触发(onchange)
![](https://img.php.cn/upload/image/212/980/599/1586083801531459.png)
![](https://img.php.cn/upload/image/246/210/230/1586083808171092.png)
- 显示文本内容改变时字体变绿(onselect)
![](https://img.php.cn/upload/image/594/900/422/1586083842408408.png)
表单域分组元素常用属性
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>表单的属性</title>
</head>
<body>
<form action="login.php">
<fieldset name="bese">
<legend>基本信息</legend>
<section>
<input type="email" name="email" placeholder="邮箱:" autofocus />
<input type="text" name="username" placeholder="用户名:" />
<input type="password" name="password" placeholder="密码:" />
</section>
</fieldset>
<button type="submit" formmethod="POST" formtarget="_blank">提交</button>
</form>
</body>
</html>
- 表单效果显示
![](https://img.php.cn/upload/image/569/235/617/1586087272913639.png)
![](https://img.php.cn/upload/image/209/213/919/1586087286806187.png)