1:checkbox的全选与反选
html代码
<form> <fieldset data-role="controlgroup" data-iconpos="left"> <input type="checkbox" name="cbAll" id="cbAll"> <label for="cbAll" class="bold"><ul class="ub-f1 tx-c ubb ub ub-ver bold"> <ul class="ulev2 ub"><li class="ub-f1 widL">设备名称</li><li class="ub-f1 widC">设备类型</li><li class="ub-f1 widR">设备品牌</li></ul></ul></label> <input type="checkbox" name="subBox" id="cbTwo"> <label for="cbTwo"> <ul class="ub-f1 tx-c ub ub-ver pointer"> <ul class="ulev1 ub"><li class="ub-f1 widL">台式机</li><li class="ub-f1 widC">办公用品</li><li class="ub-f1 widR">联想</li></ul></ul></label> <input type="checkbox" name="subBox" id="cbThree"> <label for="cbThree"> <ul class="ub-f1 tx-c ub ub-ver pointer"> <ul class="ulev1 ub"> <li class="ub-f1 widL">打印机</li><li class="ub-f1 widC">办公用品</li><li class="ub-f1 widR">佳能</li></ul></ul></label> <input type="checkbox" name="subBox" id="cbFour"> <label for="cbFour"> <ul class="ub-f1 tx-c ub ub-ver pointer"> <ul class="ulev1 ub"> <li class="ub-f1 widL">IPAD</li><li class="ub-f1 widC">电子产品</li><li class="ub-f1 widR">IPHONE</li></ul></ul></label> </div> </fieldset> </form>
js 代码
$("#cbAll").click(function(){ if($("#cbAll").is(":checked")){ $("[name=‘subBox‘]").attr( "checked", true ).checkboxradio( "refresh" ); }else{ $("[name=‘subBox‘]").attr( "checked", false ).checkboxradio( "refresh" ); } });
时间: 2024-11-05 20:51:11