在转发器内检查复选框时禁用输入

时间:2016-08-10 02:09:26

标签: jquery

我的页面加载时运行

$(document).ready(function() {
$(".indent1").each(function(){
        if($(":checkbox").is(':checked')){
            $('input[type="text"]').prop("disabled", true);
        }
});});

代码错误地禁用了第二个转发器中的文本框 即使复选框未锁定。 如何才能正确禁用第一个文本框? html page with text incorrectly disabled in 2nd repeater 罗宾

1 个答案:

答案 0 :(得分:0)

您的功能会禁用每个 from flask import abort @app.route("/some_route") def some_route(): try: # do something except SomeException: abort("Some message", 400) ,而不仅仅是转发器内的 input[type=text]。假设您尝试禁用的输入是.indent1的孩子,请尝试以下操作:

$(document).ready(function() {
  $(".indent1").each(function(){
    var $checkbox = $(this).find(':checkbox');
    var $input = $(this).find('input[type="text"]');
    if($checkbox.is(':checked')){
      $input.prop("disabled", true);
    }
  });
});