input标签checkbox选中触发事件的方法

1.方法一

<input type="checkbox" onclick="checkboxOnclick(this)" />
 
<script>
 
function checkboxOnclick(checkbox){
 
if ( checkbox.checked == true){
 
//Action for checked
 
}else{
 
//Action for not checked
 
}
}
 

2.方法二

  $('#allSelect').click(function () {

        if ($('#allSelect').prop('checked') == true) {
            $("[all='1']").prop('checked', true);
        } else {
            $("[all='1']").prop('checked', false);
        }

    })

猜你喜欢

转载自www.cnblogs.com/wuchenggong/p/9588336.html