+ 1
Javascript button condition
How do I add conditions to my button in javascript
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;
}
}
+ 3
Describe more in Description - what kind of condition is needed, and for what purpose. Clear and descriptive detail attracts contributors đ
+ 3
Divya Mohan thanksđ
, must have been a typo or somethingđ
+ 1
Vachila64â
it would be onclick="dothis()" As you r a function here.