perform an action on checkbox checked or unchecked event on html form

前端 未结 7 2297
遥遥无期
遥遥无期 2020-12-06 09:40

I have a checkbox on a form which is unchecked by default as usual. now I want to perform two separated actions on checked and unchecked state of this checkbox.

this

7条回答
  •  一生所求
    2020-12-06 09:48

    Given you use JQuery, you can do something like below :

    HTML

    syn

    JS

    function doalert() {
      if ($("#g01-01").is(":checked")) {
        alert ("hi");
      } else {
        alert ("bye");
      }
    }
    

提交回复
热议问题