checkbox复选框,让其勾选时触发一个事件,取消勾选时不触发


jQuery对CheckBox复选框操作

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="js/jquery-2.1.0.js" type="text/javascript"></script>
<script type="text/javascript">
function chk() {
    //当选中input为4时,其他选项清除选中并锁定,取消4选定,锁定解除 
    if ($("#fr").prop("checked")==true) {
        $("input[type='checkbox']").prop("checked",false);
        $("input[type='checkbox']").prop("disabled",true);
        $("#fr").prop("checked",true);
        $("#fr").prop("disabled",false);
    }else{
        $("input[type='checkbox']").prop("disabled",false);
    }
}
</script>
</head>
<body>
<input type="checkbox" name="text" value="00"/>0
<input type="checkbox" name="text" value="01"/>1
<input type="checkbox" name="text" value="02"/>2
<input type="checkbox" name="text" value="03"/>3
<input type="checkbox" name="text" value="04" id="fr" onclick="chk()"/>4
</body>
</html>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM