+ 1

Javascript button condition

How do I add conditions to my button in javascript

20th Sep 2020, 12:11 AM
Haleu Bv
Haleu Bv - avatar
5 Answers
+ 2
I'm not sure but I understand you correctly, you mean something like this? In the HTML; <button onclick="dothis"> Click be to do alert hu if your condition us true</button> In the JavaSricpt; var condition = true; //This cam be any condition though; function dothis(){ If(conditon==true/*You can make this any condition though, even tho check if 2<1*/){ //What you want to do; } }
20th Sep 2020, 12:45 AM
Vachila64โ˜•
Vachila64โ˜• - avatar
+ 3
Describe more in Description - what kind of condition is needed, and for what purpose. Clear and descriptive detail attracts contributors ๐Ÿ‘
20th Sep 2020, 12:35 AM
Ipang
+ 3
Divya Mohan thanks๐Ÿ˜…, must have been a typo or something๐Ÿ˜…
20th Sep 2020, 3:51 PM
Vachila64โ˜•
Vachila64โ˜• - avatar
+ 1
Vachila64โ˜• it would be onclick="dothis()" As you r a function here.
20th Sep 2020, 4:08 AM
Divya Mohan
Divya Mohan - avatar