簡體   English   中英

使用javascript單擊按鈕后如何禁用特定表行中的復選框?

[英]How to disable checkbox in a specific table row after clicking a button using javascript?

我已經有一個代碼,可以在單擊按鈕后禁用啟用元素。 但是,使用addClass("disabled")禁用復選框不起作用。 我該怎么做? 請看下面我的代碼。 非常感謝。

td:nth-child(3)td:nth-child(4)正常工作,但td:nth-child(1)復選框禁用不起作用。

 $(document).on('click', '.generate', function(e){

        e.preventDefault();

          var $row = $(this).closest("tr"),

              $tds1 = $row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").addClass("disabled");

              $tds3 = $row.find("td:nth-child(3) a.generate").addClass("disabled");
              $tds4 = $row.find("td:nth-child(4) a.btn-showAmort").removeClass("disabled");

      });

要禁用復選框,請使用屬性disabled css類將無效。

$tds1 = $row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").attr("disabled", true);

您不僅需要為復選框添加addClass,還需要將attribute設置為true來禁用這樣的復選框。

 $row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").addClass("disabled", true);
 OR
 $row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").addClass("disabled",false)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM