为了账号安全,请及时绑定邮箱和手机立即绑定

js 中的多个输入......?

js 中的多个输入......?

守候你守候我 2021-06-02 00:10:18
它有效 - 当输入 #key1 为空时,我无法单击按钮。但我需要使用两个输入 - #key1 和 #key2。待办事项 - 当两者都为空或 1/2 时,没有人不能点击按钮。谢谢!!<script type='text/javascript' src='http://code.jquery.com/jquery.min.js'></script><script type='text/javascript'>  $(function() {    $('#key1').keyup(function() {      if ($(this).val() == '') {        //Check to see if there is any text entered        // If there is no text within the input ten disable the button        $('.enableOnInput').prop('disabled', true);      } else {        //If there is text in the input, then enable the button        $('.enableOnInput').prop('disabled', false);      }    });  });</script>
查看完整描述

2 回答

?
桃花长相依

TA贡献1860条经验 获得超8个赞

不确定我是否理解但告诉我


<script type='text/javascript'>

  $(function() {

    var button1 = $('#key1');

    var button2 = $('#key2');


    function keyUp(){

      console.log('1', button1.val());

      console.log('2', button2.val());


      var hasValue = ( button1.val() !== '' || button1.val() !== '');

      $('.enableOnInput').prop('disabled', hasValue);

    }


    button1.keyup(keyUp);

    button2.keyup(keyUp);

  });

</script>


查看完整回答
反对 回复 2021-06-03
  • 2 回答
  • 0 关注
  • 130 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信