+ 5

[HTML] How to make a button??

I know how to make the button. But when I click it I want it to do someting, Like displaying a text.

23rd Feb 2018, 3:30 PM
InDeedOut
InDeedOut - avatar
7 Answers
+ 12
create the element with a onclick attribute <button onclick="foo()">I'm a button!</button> create the function in your script function foo(){ alert("button was clicked!!!"); }
23rd Feb 2018, 3:39 PM
Burey
Burey - avatar
23rd Feb 2018, 3:33 PM
Burey
Burey - avatar
+ 7
<button>Click Me!</button> add attributes as a normal tag like class, id etc.. to play with button you can use JavaScript dom events.. here is DOM reference:šŸ˜Š https://www.sololearn.com/learn/JavaScript/2752/
23rd Feb 2018, 3:38 PM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 2
Sorry, HTML
23rd Feb 2018, 3:35 PM
InDeedOut
InDeedOut - avatar
+ 2
<div id="d1" style="display: none">The text</div> <button onclick="document.getElementById('d1').style. display = 'block'">click me to see text </button>
23rd Feb 2018, 3:39 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 1
here is code if you want explanation tell me https://code.sololearn.com/Wbn77J2Yx8fp/?ref=app
23rd Feb 2018, 3:39 PM
Raj Chhatrala
Raj Chhatrala - avatar
0
ok
23rd Feb 2018, 3:38 PM
Raj Chhatrala
Raj Chhatrala - avatar