+ 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 ?
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");
}
+ 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
+ 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.
+ 8
They can do a variety of things, usually onclick events.
+ 4
sneeze it's obvious that functions are part of JavaScript.
I thought you'd know that's why I didn't mention it.
+ 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 ?
+ 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">
+ 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
+ 4
Please read all given answers before posting a new answer.
+ 3
Is the function Javascript or HTML ?
+ 3
HTML button element represents a clickable button,used to submit forms or anywhere in a document for accessible,standard button functionality.
+ 3
Jest it performs an action
+ 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.
+ 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 ....
+ 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.
+ 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.
+ 1
yes u can use in place of ur zip
- 1
Button do for user like a submit
Like enter buttton in keybord