How can I check if a checkbox is checked?

前端 未结 14 1393
轮回少年
轮回少年 2020-11-22 14:28

I am building a mobile web app with jQuery Mobile and I want to check if a checkbox is checked. Here is my code.



        
14条回答
  •  生来不讨喜
    2020-11-22 14:49

    I am using this and it works for me with Jquery:

    Jquery:

    var checkbox = $('[name="remember"]');
    
    if (checkbox.is(':checked'))
    {
        console.log('The checkbox is checked');
    }else
    {
        console.log('The checkbox is not checked');
    }
    

    Is very simple, but work's.

    Regards!

提交回复
热议问题