【问题标题】:How to dim an input box after another input box is filling?填充另一个输入框后如何使输入框变暗?
【发布时间】:2019-07-02 06:50:03
【问题描述】:

我有一个两个输入框,其中只有一个需要填充,另一个是暗淡的。

我的问题是,我成功使输入框A被填充,输入框B变暗,但是我清除输入框A后,输入框B仍然变暗。

这是我的代码。

$('#myCodeA').textbox( {
  onChange : function(value){
    if (value !== 'NULL'){
      $('#myCodeB').textbox({'disabled':true});
    }else{
      $('#myCodeB').textbox({'disabled':false});
    }
    }
});

$('#myCodeB').textbox( {
  onChange : function(value){
    if (value !== 'NULL'){
      $('#myCodeA').textbox({'disabled':true});
    }else{
      $('#myCodeA').textbox({'disabled':false});
    }
    }
});

我希望当输入框 A 清晰时,输入框 B 不会变暗,但它仍然变暗

对不起我的英语:)

【问题讨论】:

    标签: javascript jquery onchange onselect


    【解决方案1】:

    使用 Jquery 的 keyup() 事件代替 onChange()

            $("#myCodeA").keyup(function () {
    
                if ($(this).val().length > 0) {
    
                    $("#myCodeB").prop("disabled", true);
    
    
                } else {
    
                    $("#myCodeB").prop("disabled", false);
                }
    
            });
    
    
            $("#myCodeB").keyup(function () {
    
                if ($(this).val().length > 0) {
    
                    $("#myCodeA").prop("disabled", true);
    
                } else {
    
                    $("#myCodeA").prop("disabled", false);
                }
    
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-13
      • 2018-03-08
      • 2020-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多