How to listen to when a checkbox is checked in Jquery

前端 未结 7 1856
栀梦
栀梦 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:36

    Try this

    $('input:checkbox').change(function(){
       if(this.checked)
          alert('checked');
       else
          alert('not checked');
    });
    
    0 讨论(0)
提交回复
热议问题