Registering jQuery click, first and second click

前端 未结 9 879
佛祖请我去吃肉
佛祖请我去吃肉 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:04

    Or this :

    var clicks = 0;
    
    $('.myClass').click(function() {
        if (clicks == 0){
            // first click
        } else{
            // second click
        }
        ++clicks;
    });
    

提交回复
热议问题