jQuery :checkbox 选择器
实例
选择所有 type="checkbox" 的 <input> 元素:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$(":checkbox").wrap("<span style='background-color:red'>");});</script></head><body><form action="">姓名: <input type="text" name="user"><br>我有一辆自行车: <input type="checkbox" name="vehicle" value="Bike"><br>我有一辆汽车: <input type="checkbox" name="vehicle" value="Car"><br>我有一架飞机: <input type="checkbox" name="vehicle" value="Airplane"><br><input type="submit"></form><p>注意:我们使用 jQuerys .wrap 方法高亮显示所选元素,因为 Firefox 不支持复选框的背景色。</p></body></html>
定义与用法
:checkbox 选择所有 type="checkbox" 的 input 元素
语法
$(":checkbox")