+ 1
While button pressed do...?
Hi, im looking for a solution that i know if a button A is pressed. For example. if(button a is pressed do...) but just if its pressed how can i know that. i need that for: if button a is pressed dont do the function of the eventlisener of button b
5 ответов
+ 7
You can work in html part as :
button onclick = function1()
JS part :
Define function 1.
So the crux is that you can use onclick attribute of button tag to call required function and put your conditions in that function.
0
no i cant i want to compare to events how i can do that?
0
like if( button a is pressed and button b not) do ....
0
so far i have this:
https://code.sololearn.com/Wn47cR40Hufj
0
jack First you have to grab the button a using dom node selection. Then check whether button b is pressed using same. Then have a if condition to check which button is pressed. Use
let button1 =document.getElementsByTagName("body").getElementsByTagName("button").[0]; to select the first button in the body tag. Then repeat it to select the next one as button2