Watch for change of the input[type=“checkbox”]

前端 未结 5 1974
旧时难觅i
旧时难觅i 2021-02-13 15:17

How can I run a function on checkbox change?

I\'m trying to write small checkbox replacing function base on that - but I\'m doing something wrong.

Code:

5条回答
  •  你的背包
    2021-02-13 15:35

    Is this what you want? I am under the impression that you are over-complicating things.

    $('input[type="checkbox"]').change(function() {
        alert ("The element with id " + this.id + " changed.");
    });
    

提交回复
热议问题