How to do “If Clicked Else ..”

后端 未结 8 1570
灰色年华
灰色年华 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:26

     var flag = 0;
    
     $('#target').click(function() {
        flag = 1;
     });
    
     if (flag == 1)
     {
      alert("Clicked");
     }
     else
     {
       alert("Not clicked");
     }
    

提交回复
热议问题