Web前端基础(19)jQuery对文本框和表单的操作
·
大约 700 个字
·
预计 4
分钟 读完
单行文本框
首先在网页中创建一个表单,代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
input:focus, textarea:focus{
border:1px solid #f00;
background: #fcc;
}
</style>
</head>
<body>
<form action="#" method="POST" id="regForm">
<legend>个人基本信息</legend>
<div>
<label for="username">名称:</label>
<input id="username" type="text"></label>
</div>
<div>
<label for="pass">密码:</label>
<input id="pass" type="password"></label>
</div>
<div>
<label for="msg">详细信息:</label>
<textarea id="msg"></textarea>
</div>
</form>
</body>
</html>
|
但是IE6并不支持除超链接元素之外的:hover伪类选择器,此时可以用jQuery来弥补。
阅读更多