How do I check whether a checkbox is checked in jQuery?

前端 未结 30 3440
花落未央
花落未央 2020-11-21 04:44

I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery.

For example, if the age checkbox is

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 04:58

    Use:

    UDB
    Prasad
    
    $('input#abc').click(function(){
      if($(this).is(':checked'))
      {
        var checkedOne=$(this).val()
        alert(checkedOne);
    
        // Do some other action
      }
    })
    

    This can help if you want that the required action has to be done only when you check the box not at the time you remove the check.

提交回复
热议问题