那不绑定click就可以了啊 

解决方案 »

  1.   

    change事件不是因为点击按钮才触发的啊,应该是onblur时,就会触发change事件,就是当你的input框失去焦点时,就会触发这个change事件。按你说的意思,我觉得change事件是不需要的,可以把change事件的处理逻辑,放到click事件内处理的啊。
      

  2.   

    change事件需要对文本框的输入进行校验,确认按钮的click事件需要对所有的输入进行校验,不能放在一起。
      

  3.   


    <!doctype html>
    <html lang="zh-cn">
    <head>
        <meta charset="utf-8">
    <style>*{margin:0;padding:0;}div{padding:20px;}a{padding:10px;}</style>
        <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    </head>
    <body>
    <script>
    $(function(){
    var $b1 = $("#b1");
    $b1.on("click",function(){
    alert("检测中...")
    });
    $("#t1").on({
    change:function(){
    $b1.off("click","**");
    alert("change!")
    $b1.on("click");
    }
    })
    })

        </script>
        <div id="wrapper">
         <header id="header"></header>
            <div>
             <input type="text" id="t1" placeHolder="hello,world!" />
                <input type="button" id="b1" value="检测" />
            </div>
        </div>
    </body>
    </html>
      

  4.   


    <!doctype html>
    <html lang="zh-cn">
    <head>
        <meta charset="utf-8">
    <style>*{margin:0;padding:0;}div{padding:20px;}a{padding:10px;}</style>
        <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    </head>
    <body>
    <script>
    $(function(){
    var $b1 = $("#b1");
    var $t1 = $("#t1");
    var handleClick = function(e){
    console.log("检测中...")
    }
    $b1.on("click",handleClick);
    $t1.on({
    change:function(){
    $b1.off("click",handleClick);
    console.log("change!");
    setTimeout(function(){
    $b1.on("click",handleClick);
    },100);
    }
    })
    })

        </script>
        <div id="wrapper">
         <header id="header"></header>
            <div>
             <input type="text" id="t1" placeHolder="hello,world!" />
                <input type="button" id="b1" value="检测" />
            </div>
        </div>
    </body>
    </html>
      

  5.   

    假设文本框是textInput, 按钮是enterButton:textInput.addEventListener('change', onTextChange, false);enterButton.addEventListener('click', onButtonCLick, false);var _valid = true;    //当前文本是否校验通过function onTextChange(){
        if(校验条件){
             _valid = true;
        }else{
            _valid = false;
        }
    }function onButtonClick(){
        if(_valid ===true){
               //如果文本校验通过
        }else{
               //否则
        }
    }change事件会在文本的编辑过程中不断被触发, 而click事件只会在点击时触发一次.
      

  6.   

    那你把按钮的click事件去掉不就行了~~~我擦~