jsp页面多选框之JavaScript
全选,全不选,反选,以及复选框同步
<body> <input type="checkbox" name="checkAll"> <input type="checkbox" name="checkOne" value="${g.gid }"> <input type="button" value="全选" "qx()"> <input type="button" value="全不选" "qbx()"> <input type="button" value="反选" "fx()"> </body
JavaScript:
/* 多选框 */
function qx(){
$("[name='checkAll'],[name='checkOne']").prop("checked",true)
}
function qbx(){
$("[name='checkAll'],[name='checkOne']").prop("checked",false)
}
function fx(){
$("[name='checkOne']").map(function(){
this.checked =! this.checked
})
}
$(function(){
$("[name='checkAll']").click(function(){
var v = $(this)
$("[name='checkOne']").prop("checked",v.prop("checked"))
})
})