It’s a lost question but I am new | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

It’s a lost question but I am new

How do I make a buton that does something

11th Aug 2023, 2:06 PM
Olek Olszycki
5 Answers
+ 2
What are you trying to do? You can (assuming you are using HTML) use <input type=“submit”> to create a button that submits a form, or a <button> with an onclick event attribute to trigger an action using JavaScript. How to implement the action (handling a form, changing something on the page, or something else) will depend on what your goal is.
11th Aug 2023, 2:11 PM
Dan
+ 1
There are some different ways to make a button do something in Web development. 1: Using the onclick attributes: (Syntax: onclick = "JS_function_name()") This attribute would trigger a specific function once the element with this attribute is clicked. There are many other attributes with familiar functionality such as: onchange, onfocus..(correct me if I'm wrong) 2. Using JS: In JS, you can give it more functionality than just one function like the onclick ones. This can be done by using addEventListener(), click(), on(), and some more. [The on() function only available in jQuery]
11th Aug 2023, 3:12 PM
Dragon RB
Dragon RB - avatar
0
Thanks
11th Aug 2023, 2:14 PM
Olek Olszycki
0
Thanks
11th Aug 2023, 3:14 PM
Olek Olszycki
0
use <button> attribute to make a button
13th Aug 2023, 9:26 AM
Alhaaz
Alhaaz - avatar