Get checkbox status using javascript

前端 未结 5 1471
时光说笑
时光说笑 2021-01-02 05:40

This is my checkbox HTML code

 class=\"che         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-02 06:21

    Simply bind an onchange handler to your checkbox.

    $("#termsCheckbox").change(function() {
    
        // class will be removed if checked="checked"
        // otherwise will be added
        $(this).toggleClass("terms_error", !this.checked);
    }).change(); // set initial state
    

提交回复
热议问题