jQuery选择器-表单对象属性选择器示例

来源:互联网 发布:欧亚联盟知乎 编辑:程序博客网 时间:2024/06/05 18:21
<span style="font-size:24px;color:#ff0000;"><!DOCTYPE html><html><head>    <meta http-equiv="content-type" content="text/html; charset=UTF-8">    <script type="text/javascript" src="js/jquery-2.2.4.js"></script></head><body><form>    <input type="text" name="email" disabled="disabled" />    <input type="text" name="password" disabled="disabled" />    <input type="text" name="id" />    <input type="checkbox" name="newsletter" checked="checked" value="Daily" />    <input type="checkbox" name="newsletter" value="Weekly" />    <input type="checkbox" name="newsletter" checked="checked" value="Monthly" />    <select id="provinceID">        <option value="1">广东</option>        <option value="2" selected="selected">湖南</option>        <option value="3">湖北</option>    </select></form><script type="text/javascript">    //1)查找所有可用的input元素的个数    //alert($("input:enabled").size());    //2)查找所有不可用的input元素的个数    //alert($("input:disabled").size());    //3)查找所有选中的复选框元素的个数    //alert($(":checkbox:checked").size());    //4)查找所有未选中的复选框元素的个数    //alert($(":checkbox:not(:checked)").size());    //5)查找所有选中的选项元素的个数    alert($("select option:selected").size());</script></body></html></span>










0 0
原创粉丝点击