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>

 

posted @ 2019-05-27 19:30  南山下的采药人  阅读(10571)  评论(0编辑  收藏  举报