Is there the opposite of click event in Jquery?

This question already has an answer here:

  • How do I detect a click outside an element? 76 answers

  • Yes, you can use off and give the event handler:

    $("#forminput").off("click");
    

    But if you want to restore to an earlier state, it is always wise to use just CSS for presentation and then use JavaScript to toggle between the classes. Considering your current situation, I believe just CSS is enough.

    input {color: #999; padding: 10px; width: 200px;}
    input:focus {color: #000;}
    <input type="text" value="Default Gray, Click Black." />

    在这里您可以使用解决方案https://jsfiddle.net/8gygvdwy/

    $('input[type=text]').focus(function(){
    	$(this).css({
      	'background': '#ccc'
      });
    }).focusout(function(){
    	$(this).css({
      	'background': '#fff'
      });
    });
    
    $('input[type=button]').click( function(){
    	$('input[type=text]').css({
      	'background': '#fff'
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <input type="text" id="search" />
    <input type="button" value="Submit" />
    链接地址: http://www.djcxy.com/p/83048.html

    上一篇: 困境:何时使用碎片与活动:

    下一篇: 在JQuery中有没有与点击事件相反的东西?