function checkAll(tag,flag){//得到所有checkvar checkboxs = $(tag).closest("table").find(":checkbox");for(var i=0;i<checkboxs.length;i++){if(checkboxs[i].name=="importedNetItemId"){if(flag){checkboxs[i].checked = true;checkboxs[i].setAttribute("checked", "checked")}else{checkboxs[i].checked = false;checkboxs[i].setAttribute("checked", "unchecked")//这是dom元素中设置属性值的方法,此处不能采用attr() }}}}
$("#checkJoiner").live("click",function(){//点击全选if(this.checked){$("input[delTag='delId']").each(function(){this.checked=true})}else{$("input[delTag='delId']").each(function(){this.checked=false})}});
<input type='checkbox' value="$v['joinerid']" name='delJoiner' delTag='delId' class='checkNetMusic' attr_aid=".$v['aid']."/>