jQuery 表单选择器
jQuery 代碼:
<script type="text/javaScript">
$(document).ready(function(){
$("#form1 input:enabled").val("這里變化了");//改變表單內可用<input> 元素
$("#form1 input:disabled").val("這里也變了"); //改變表單內不可用<input>元素
$("input:checked").length;//獲取多選框選中的個數
$("select :selected").text();//獲取下拉框選中的內容
$("#form2 :input").length; //獲取表單元素的個數
$("#form2 :text").length; //獲取表單內當行文本的個數
$("#form2 :password").length;//獲取表單內密碼框的個數
});
</script>
?
?
?
?
?
css 代碼
<form action="#" id="form1">
可用元素:<input name="add" value="可用文本框"> <br/>
不可用元素:<input name="email" disabled="disabled" value="不可用文本框"> <br />
可用元素:<input name="che" value="可用文本框"> <br/>
不可用元素:<input name="name" disabled="disabled" value="不可用文本框"> <br />
多選框:<br/>
<input type="checkbox" name="newsletter" checked="checked" value="test1" />test1
<input type="checkbox" name="newsletter" value="test2" />test2
<input type="checkbox" name="newsletter" value="test3" />test3
<input type="checkbox" name="newsletter" checked="checked" value="test4" />test4
<input type="checkbox" name="newsletter" value="test5" />test5
<div></div>
<br /><br />
下拉列表1:<br />
<select name="test" multiple="multiple" style="height:100px">
<option>浙江</option>
<option selected="selected">湖南</option>
<option>浙江</option>
<option selected="selected">湖南</option>
<option>浙江</option>
<option>浙江</option>
</select>
<br /><br />
下拉列表2:<br />
<select name="test" multiple="multiple" style="height:100px">
<option>浙江</option>
<option>湖南</option>
<option>浙江</option>
<option selected="selected">湖南</option>
<option>浙江</option>
<option>浙江</option>
</select>
<div></div>
</form>
<br>
<br>
<br>
<br>
<br>
<form action="#" id="form2">
<input type="button" value="button" /> <br/>
<input type="checkbox" name="c" />1
<input type="checkbox" name="c" />2
<input type="checkbox" name="c" />3 <br/>
<input type="file" /><br/>
<input type="hidden" /> <div style="display:none">test</div> <br/>
<input type="image" /><br/>
<input type="password" /><br/>
<input type="radio" name="a" />1<input type="radio" name="a" />2 <br/>
<input type="reset" /><br/>
<input type="submit" value="提交" /><br/>
<input type="text" /><br/>
<select><option>option</option></select><br/>
<textarea></textarea><br/>
<button>Button</button><br/>
</form>
?
轉載于:https://www.cnblogs.com/qdmaomao/p/4485509.html
總結
以上是生活随笔為你收集整理的jQuery 表单选择器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Electron - 创建跨平台的桌面客
- 下一篇: (转)java中对集合对象list的几种