0
Do buttons trigger stuff?
I was testing code when I saw <button>. Can buttons trigger stuff in web language? And can it trigger stuff in games?
5 odpowiedzi
0
Yes, all you have to do is attach an onclick attribute to it, containing a Javascript function to run. For example:
<button onclick="runFunction()">
However, I believe buttons are outdated, and what you should do is use a input tag:
<input type="button" onclick="runFunction()">
0
All you have to do is use the onclick attribute for button, and attach a function written in Javascript to it. A function is basically a block of code that can be reused. That's as simple as I can explain it. The button basically runs the function once it's been clicked, or "on"+"click"; this is done through the onclick attribute.
0
You just place it in the button tag, like in my previous post.
- 1
Explain it more simpler.
- 1
What is the onclick and how do you do it,