剑道复选框勾选事件

Jey*_*ari 3 javascript checkbox events kendo-ui

我试图捕捉剑道复选框事件,但我无法让它工作。我确定我错过了一些东西。在这个简单的事情上花了一个多小时,我很累。以下是代码片段。

HTML

<div class="bottomPadding row">
    <div class="col-md-4 col-sm-4 col-xs-12 col">
        <label>Send Activation Link</label>
    </div>
    <div class="col-md-6 col-sm-6 col-xs-12 col">
        <input id="sendLink" type="checkbox" data-bind="checked: Account.IsLink" />
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

和 JS 代码,

$("#sendLink").click(function () {
    if (this.checked) {
        console.log("hit");
    }
});
Run Code Online (Sandbox Code Playgroud)

请纠正我哪里搞砸了。

PS:我提到了几个 SO 答案,有些没有答案,有些答案在我的情况下不起作用。

Geo*_*geB 6

我已经在我的机器上运行了你的代码并收到了点击事件,这是我的代码:

    <div class="row">
    <div class="col-md-4 col-sm-4 col-xs-12 col">
        <label>Send Activation Link</label>
    </div>
    <div class="col-md-6 col-sm-6 col-xs-12 col">
        <input id="sendLink" type="checkbox" data-bind="checked: Account.IsLink" />
    </div>
</div>
<script>
    $(document).ready(function () {
        clickHookup();
    })
</script>
Run Code Online (Sandbox Code Playgroud)

在我的 JS 文件中:

function clickHookup() {
    $("#sendLink").click(function () {
      if (this.checked) {
        console.log("hit");
      }
    });
}
Run Code Online (Sandbox Code Playgroud)