0

How to use the if statments in buttons? For example, When the button pressed it prints'Hello world!'

I tried ' if (**button id var**== true) { **statment** }' and nothing happened

16th May 2019, 7:08 PM
omar
2 ответов
+ 3
Please specify the language in Relevant Tags, it helps others to identify your problem and offer the proper solution. https://www.sololearn.com/Discuss/333866/?ref=app
16th May 2019, 7:47 PM
Ipang
+ 2
omar Please don't make duplicate questions, I see you repost this question. Take a look at this sample, and tell me if you have a question, but don't make duplicate questions. <!DOCTYPE html> <html> <head> <title>onclick event</title> </head> <body> <!-- when button is clicked executed JS function "showAlert" (defined below) --> <button type="button" onclick="showAlert();">Click here!</button> </body> <script> function showAlert() { alert("I am alert window.\nI come here because you push the button"); } </script> </html>
17th May 2019, 4:32 PM
Ipang