jQuery表單域選擇器用法分析
本文實(shí)例分析了jQuery表單域選擇器用法。分享給大家供大家參考。具體如下:
表單域是指網(wǎng)頁(yè)中的input,textarea, select和button元素。
1. :input選擇器
2. :text選擇器
3. :password選擇器
4. :radio選擇器
5. :checkbox選擇器
6. :file選擇器
7. :image選擇器
8. :hidden選擇器
9. :submit選擇器
10. :reset選擇器
簡(jiǎn)單實(shí)例:
<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="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"); //注意沒有冒號(hào)
$(":submit").attr("id", "btn1");
$(":reset").attr("name", "btn");
$("textarea").attr("value", "文本域"); //注意沒有冒號(hào)
});
</script>
</head>
<body>
<table width="730" height="145" border="1">
<tr>
<td width="113" height="23">文本框</td>
<td width="209"><input type="text"/></td>
<td width="93">密碼框</td>
<td width="287"><input type="password" /></td>
</tr>
<tr>
<td height="24">單選按鈕</td>
<td><input type="radio" /><input type="radio" /></td>
<td>復(fù)選框</td>
<td><input type="checkbox" /><input type="checkbox" /></td>
</tr>
<tr>
<td height="36">圖像</td>
<td><input type="image" /></td>
<td>文件域</td>
<td><input type="file" /></td>
</tr>
<tr>
<td height="23">隱藏域</td>
<td><input type="hidden" />(不可見)</td>
<td>下拉列表</td>
<td><select><option>選項(xiàng)一</option><option>選項(xiàng)二</option><option>選項(xiàng)三</option></select></td>
</tr>
<tr>
<td height="25">提交按鈕</td>
<td><input type="submit" /></td>
<td>重置按鈕</td>
<td><input type="reset" /></td>
</tr>
<tr>
<td valign="top">文本區(qū)域:</td>
<td colspan="3"><textarea cols="70" rows="3"></textarea></td>
</tr>
</table>
</body>
</html>
效果圖如下所示:
希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。
- 使用jQuery內(nèi)容過濾選擇器選擇元素實(shí)例講解
- jquery選擇器之內(nèi)容過濾選擇器詳解
- jQuery的內(nèi)容過濾選擇器學(xué)習(xí)教程
- jQuery內(nèi)容過濾選擇器用法示例
- jQuery內(nèi)容過濾選擇器與子元素過濾選擇器用法實(shí)例分析
- jQuery表單對(duì)象屬性過濾選擇器實(shí)例詳解
- jQuery選擇器之表單元素選擇器詳解
- jquery表單對(duì)象屬性過濾選擇器實(shí)例分析
- jQuery表單元素選擇器代碼實(shí)例
- jQuery表單元素過濾選擇器用法實(shí)例分析
- jQuery內(nèi)容選擇器與表單選擇器實(shí)例分析
相關(guān)文章
jQuery實(shí)現(xiàn)的動(dòng)態(tài)伸縮導(dǎo)航菜單實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的動(dòng)態(tài)伸縮導(dǎo)航菜單,實(shí)例分析了jQuery鼠標(biāo)事件及animate、hide等方法的使用技巧,需要的朋友可以參考下2015-05-05Easy UI動(dòng)態(tài)樹點(diǎn)擊文字實(shí)現(xiàn)展開關(guān)閉功能
這篇文章主要介紹了Easy UI動(dòng)態(tài)樹點(diǎn)擊文字實(shí)現(xiàn)展開關(guān)閉功能,需要的朋友可以參考下2017-09-09jQuery焦點(diǎn)圖輪播插件KinSlideshow用法分析
這篇文章主要介紹了jQuery焦點(diǎn)圖輪播插件KinSlideshow用法,結(jié)合實(shí)例形式較為詳細(xì)的分析了jQuery焦點(diǎn)圖輪播插件KinSlideshow的參數(shù)含義與使用方法,需要的朋友可以參考下2016-06-06