How can I execute a function when a disabled checkbox is clicked?

前端 未结 6 2442
轮回少年
轮回少年 2020-12-11 20:01

I have a checkbox on a page that is disabled until some criteria is met.

In an effort to give the user some information, I\'d like to have a \'tool tip\' display whe

6条回答
  •  遥遥无期
    2020-12-11 20:22

    If you don't want to wrap the checkbox in a div, then consider not diabling checkbox and modifying the built-in click event on the checkbox:

    document.getElementById("checkboxId").addEventListener("click", function (event) {
       event.preventDefault();
       //The code you want to be run when the checkbox is clicked
    });
    

提交回复
热议问题