How can i give a function to a button in HTML5? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i give a function to a button in HTML5?

I want to make a button for the user to click and access another page.

22nd Nov 2016, 10:53 PM
Silas Junior
Silas Junior - avatar
5 Answers
+ 1
"onclick" will help you )
22nd Nov 2016, 10:55 PM
Alex Shama
Alex Shama - avatar
+ 1
or simply add link in to button in HTML
22nd Nov 2016, 10:56 PM
Alex Shama
Alex Shama - avatar
+ 1
Could you please show me the sintax for doing this?
22nd Nov 2016, 10:58 PM
Silas Junior
Silas Junior - avatar
0
<a href = "http://google.com"><button title="link" value="link">button</button></a>
22nd Nov 2016, 11:04 PM
Alex Shama
Alex Shama - avatar
0
<button onclick="myFunction()">Click me</button> if you do this with JS. But in this case you must declarate function. In HTML much easier.
22nd Nov 2016, 11:09 PM
Alex Shama
Alex Shama - avatar