" /><br />
<button>
Button</button><br />
</form>
<script type="text/java script">
$("#frmTest input:submit").addClass("bg_red");
</script>
--:image图像域选择器
当一个<input>元素的“type”属性值设为“image”时,该元素就是一个图像域,使用:image
选择器可以快速获取该类全部元素。
<h3>修改表单中图像元素的背景色</h3>
<form id="frmTest" action="#">
<input type="image" src="https://www.cppentry.com/upload_files/article/85/1_7smnl__.jpg" /><br />
<br />
<img alt="" src="https://www.cppentry.com/upload_files/article/85/1_7smnl__.jpg" /><br />
</form>
<script type="text/java script">
$("#frmTest :image").addClass("bg_red");
</script>
--:button表单按钮选择器
表单中包含许多类型的按钮,而使用:button
选择器能获取且只能获取“type”属性值为“button”的<input>和<button>这两类普通按钮元素。
<h3>修改表单中按钮元素的背景色</h3>
<form id="frmTest" action="#">
<input id="Button1" type="button" value="我是普通按钮" /><br />
<input id="Submit1" type="submit" value="点我就提交" /><br />
<button> 我也是普通按钮 </button><br />
</form>
<script type="text/java script">
$("#frmTest :button").addClass("bg_blue");
</script>
--:checked选中状态选择器
有一些元素存在选中状态,如复选框、单选按钮元素,选中时“checked”属性值为“checked”,调用:checked可以获取处于选中状态的全部元素。
<h3>将处于选中状态的元素设为不可用</h3>
<form id="frmTest" action="#">
<input id="Radio1" type="radio" checked="checked" />
<label id="Label1" for="Radio1">
苹果</label><br />
<input id="Radio2" type="radio" />
<label id="Label2" for="Radio2">
桔子</label><br />
<input id="Checkbox1" type="checkbox" checked="checked" />
<label id="Label3" for="Checkbox1">
荔枝</label><br />
<input id="Checkbox2" type="checkbox" />
<label id="Label4" for="Checkbox2">
葡萄</label><br />
<input id="Checkbox3" type="checkbox" checked="checked" />
<label id="Label5" for="Checkbox3">
香蕉</label><br />
</form>
<script type="text/java script">
$("#frmTest :checked").attr("disabled", true);
</script>
--:selected选中状态选择器
与:checked
选择器相比,:selected
选择器只能获取<select>下拉列表框中全部处于选中状态的<option>选项元素。
<h3>获取处于选中状态元素的内容</h3>
<form id="frmTest" action="#">
<select id="Select1" multiple="multiple">
<option value="0">苹果</option>
<option value="1" selected="selected">桔子</option>
<option value="2">荔枝</option>
<option value="3" selected="selected">葡萄</option&g