Skip to content Skip to sidebar Skip to footer

How To Trigger An Event After Clicking Two Different Button In Javascript

I was wondering how I can trigger an event after two different buttons being clicked. Specifically I have some buttons with different ids and I want when I click two specific butt

Solution 1:

Just pass some sort of value whenever the button you want is clicked. For instance:

 ob.addEventListener("click",function() {onCl1(1)});
 ob1.addEventListener("click",function() {onCl1(1)});
  var i;   
functiononCl1(value){
i += value;
if(i == 2){
//do this
   }
}

So basically once these two buttons are clicked the value will equal 2 and trigger whatever you want.

Post a Comment for "How To Trigger An Event After Clicking Two Different Button In Javascript"