3

Here is the Fiddle.

So I've set up this little example of what I am trying to do. I want this checkbox to work as the following. When user tries to enable/click the checkbox (mostly for people who are not computer savvy), I would like for it to alert them saying "You must login to do this action".

I can't figure it out. I've been searching all over for an answer, and couldn't find one.

Thanks a lot in advance for all your answers!

4

2 回答 2

4

只需disabled从复选框中删除属性。此外,如果您只想在选中复选框时显示警报,请改用以下内容:

$(".check").click(function() {
    if (this.checked) {
        alert("You must sign in to do this.");
    }
});
于 2012-08-24T01:28:58.233 回答
0

删除选中和禁用属性并使用以下代码:

$(".check").click(function() {
    if ($(this).is(':checked')) alert("You must sign in to do this.");
});​

jsFiddle 示例

于 2012-08-24T01:29:41.320 回答