<!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=utf-8" />
<title>表单域选择器</title>
<script type="text/javascript" src="https://www.jb51.net/jquery-1.7.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(":text").attr("value", "文本框");
$(":password").attr("value", "密码框");
$(":radio:eq(0)").attr("checked", "true");
$(":checkbox").attr("checked", "true");
$(":image").attr("src", "ICO.ICO");
$(":file").css("width", "200px");
$(":hidden").attr("value", "已保存的值");
$("select").css("background", "#FCF"); //注意没有冒号
$(":submit").attr("id", "btn1");
$(":reset").attr("name", "btn");
$("textarea").attr("value", "文本域"); //注意没有冒号
});
</script>
</head>
<body>
<table>
<tr>
<td>文本框</td>
<td><input type="text"/></td>
<td>密码框</td>
<td><input type="password" /></td>
</tr>
<tr>
<td>单选按钮</td>
<td><input type="radio" /><input type="radio" /></td>
<td>复选框</td>
<td><input type="checkbox" /><input type="checkbox" /></td>
</tr>
<tr>
<td>图像</td>
<td><input type="image" /></td>
<td>文件域</td>
<td><input type="file" /></td>
</tr>
<tr>
<td>隐藏域</td>
<td><input type="hidden" />(不可见)</td>
<td>下拉列表</td>
<td><select><option>选项一</option><option>选项二</option><option>选项三</option></select></td>
</tr>
<tr>
<td>提交按钮</td>
<td><input type="submit" /></td>
<td>重置按钮</td>
<td><input type="reset" /></td>
</tr>
<tr>
<td valign="top">文本区域:</td>
<td colspan="3"><textarea cols="70" rows="3"></textarea></td>
</tr>
</table>
</body>
</html>
jQuery表单域选择器用法分析
内容版权声明:除非注明,否则皆为本站原创文章。