Registering jQuery click, first and second click

前端 未结 9 887
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 23:23

Is there a way to run two functions similar to this:

$(\'.myClass\').click(
    function() {
        // First click
    },
    function() {
        // Second         


        
9条回答
  •  青春惊慌失措
    2020-11-30 00:08

    When You click the selector it automatically triggers second and waiting for another click event.
    
    $(selector).click(function(e){
        e.preventDefault(); // prevent from Posting or page loading
         //do your stuff for first click;
         $(this).click(function(e){
         e.preventDefault();// prevent from Posting or page loading
          // do your stuff for second click;
         });
    });
    

    I hope this was helpful to you..

提交回复
热议问题