私のコードで構文に問題があります。 demoを参照してください。JavaScript - チェックボックスが無効になっている場合、jQueryを使用してクラスを追加してください。
私は次のコードを試しましたが、結果は何もしません。
#1。 hasAttribute():
if ($('input[type=checkbox]').hasAttribute("disabled")) {
$(this).closest('.chkbox').addClass("is-disabled");
}
#2。 ()である:
if ($('input[type=checkbox]').is("[disabled]")) {
$(this).closest('.chkbox').addClass("is-disabled");
}
// ------------------------------------------------
if ($('input[type=checkbox]').is(":disabled")) {
$(this).closest('.chkbox').addClass("is-disabled");
}
#3。小道具():
if ($('input[type=checkbox]').prop("disabled", true)) {
$(this).closest('.chkbox').addClass("is-disabled");
}
それでは私はこの問題は、ライン上にあると思う:
$(this).closest('.chkbox').addClass("is-disabled");
任意のアイデア?
ありがとうございました。
を使用でき
予想される結果は何ですか。デモはあなたが提供したコードと少し違っているようです – VladNeacsu