How to do “If Clicked Else ..”

后端 未结 8 1553
灰色年华
灰色年华 2021-01-31 05:48

I am trying to use jQuery to do something like

if(jQuery(\'#id\').click) {
    //do-some-stuff
} else {
    //run function2
}

But I\'m unsure h

8条回答
  •  伪装坚强ぢ
    2021-01-31 06:20

    A click is an event; you can't query an element and ask it whether it's being clicked on or not. How about this:

    jQuery('#id').click(function () {
       // do some stuff
    });
    

    Then if you really wanted to, you could just have a loop that executes every few seconds with your // run function..

提交回复
热议问题