How to listen to when a checkbox is checked in Jquery

前端 未结 7 1894
栀梦
栀梦 2020-12-08 12:47

I need to know when any checkbox on the page is checked:

e.g.


I tried this in Jquery



        
7条回答
  •  借酒劲吻你
    2020-12-08 13:22

    If you want to use .on this works

     jQuery('input[type=checkbox]').on('change', function() {
       if (this.checked) {
         console.log('checked');
       }
     });
    

提交回复
热议问题