检查复选框已禁用(Jquery) [英] Check Checkbox Disabled (Jquery)

查看:216
本文介绍了检查复选框已禁用(Jquery)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目的是:

如果禁用复选框,则不执行任何操作。

如果启用并选中复选框,则设置按钮的样式。

这里是我到目前为止;

The purpose is to;
If checkbox is disabled, do nothing.
If checkbox is enabled and checked, set the style of a button.
Here is what I've got so far;

 $(document).ready(function (e) {


        $(".checkbox").live("click", function () {

            if ($(this).hasAttribute('disabled')) {
                return false;
            }
            var isAnyChecked;

            $("input[type=checkbox]").each(function () {
                var checkedValue = $(this).attr("checked");
                if (checkedValue == "checked") {
                    isAnyChecked = true;
                }


            });

            if (isAnyChecked) {
                $("#<%= btnConfirm.ClientID %>").css("display", "block");

            } else {
                $("#<%= btnConfirm.ClientID %>").css("display", "none");

            }


        });  });

我试过了 .is(':disabled') .hasAttr() .prop() .attr )

推荐答案

您必须检查 disabled 属性为true: .attr('disabled')

You have to check whether the disabled attribute is true: .attr('disabled').

$ c> .is(':disabled')。

Or, better, use .is(':disabled').

这篇关于检查复选框已禁用(Jquery)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆