+ 3

What can a button do in HTML

Normally I am a c# programmer. So buttons can do anything. I tried to do something in HTML. But the only thing I could find that a button can do is "alert" (read : show a messagebox). Are there other things buttons can do ?

11th Apr 2020, 8:32 PM
sneeze
sneeze - avatar
18 odpowiedzi
+ 6
buttons can do what they are supposed to do. They can trigger an onlick event and call a function or maybe bunch of them. It can call any built in function or even a user defined function. for example: <button onclick="foo()">Bar</button> function looks like this : function foo() { console.log("hey there buddy"); }
11th Apr 2020, 9:01 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 10
<button>: The Button element You can find useful information where button element can be used here — https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
11th Apr 2020, 11:27 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 8
sneeze Buttons are used to programmatically do something, using JavaScript. Here's an example, ( don't look at the js code much ), I've tried various examples...🍻 • https://code.sololearn.com/WD47O26oKupW/?ref=app // pay attention to the html code, it only has an element :    <button>Hi there!</button> the layout is done in css and the functionality is in javascript.
11th Apr 2020, 10:35 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 8
They can do a variety of things, usually onclick events.
13th Apr 2020, 8:00 AM
Chris
Chris - avatar
+ 4
sneeze it's obvious that functions are part of JavaScript. I thought you'd know that's why I didn't mention it.
11th Apr 2020, 9:05 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 4
It is funny how you can be a professional in one language. And a beginner in another. I am a c# programmer, so I am used to one language that can do everything. Although currently with WPF, the visual side is no longer C#-language. Maybe I am looking to much to take one step at the time, first learn html and then javascript. The functions are in the same file as the button, are they ?
11th Apr 2020, 9:11 PM
sneeze
sneeze - avatar
+ 4
sneeze Yes you can put them in same file, put the function between <script> tag and you're good to go. But you can also have separate files for html and js. Then you can link the js file to html using src attribute of script. Like: <script src="folderPath/filename.js">
11th Apr 2020, 9:25 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 4
Buttons can basically do anything. You can use that in HTML and ask the button to do what you want by coding in JavaScript. onclick is the most common function. On top of that there are many more. Onmouseover, onfocus etc and etc. Learn JavaScript
13th Apr 2020, 12:53 AM
Adhith T
Adhith T - avatar
+ 4
Please read all given answers before posting a new answer.
13th Apr 2020, 7:45 AM
sneeze
sneeze - avatar
+ 3
Is the function Javascript or HTML ?
11th Apr 2020, 9:04 PM
sneeze
sneeze - avatar
+ 3
HTML button element represents a clickable button,used to submit forms or anywhere in a document for accessible,standard button functionality.
12th Apr 2020, 6:33 PM
Akshita Patel
Akshita Patel - avatar
+ 3
Jest it performs an action
13th Apr 2020, 6:29 AM
Reddy Vinay Kumar
Reddy Vinay Kumar - avatar
+ 2
&sneeze , I feel your pain. Javascript can be in another file (and often is IRL). When learning it might be easier to put in same file. Seperating increases security and modifiability.
11th Apr 2020, 9:27 PM
SQrL
SQrL - avatar
+ 2
By html you can make a clickable button. In <form> element input type= button creates a button to submit the form details. Botton element also creates button and it executes it's assigned function " onclick". It's basic idea only ....
12th Apr 2020, 8:15 PM
Dushyant Kumar Tyagi
Dushyant Kumar Tyagi - avatar
+ 2
The HTML<button> element represents a cilckable button,used to submit forms or anywhere in a document for accessible, standard button functionality. By default,HTML buttons are presented in a style resembling theplatform the user agent runs on,but you can change buttons’ appearence with CSS. You may go through https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button, and https://html.com/tags/button/ in this context.
13th Apr 2020, 6:55 AM
narayanaprasad
narayanaprasad - avatar
+ 2
En Html5 vas a encontrar por lo menos dos tipos de botones, el botón de tipo submit que te permite enviar los datos que obtengas de los campos de un formulario y el botón tipo button que te va a permitir manejar por medio de funciones en javascript o jquery cualquier cosa que desees hacer; como sumar dos valores, mostrar un alert como tu lo indicas, pasar parámetros a código php. Etc.
13th Apr 2020, 8:03 AM
Alexander Sandoval
Alexander Sandoval - avatar
+ 1
yes u can use in place of ur zip
13th Apr 2020, 4:06 AM
Manoj Kumar Das
- 1
Button do for user like a submit Like enter buttton in keybord
12th Apr 2020, 2:36 PM
Gohil Priyanshu Pareshkumar
Gohil Priyanshu Pareshkumar - avatar