+ 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.
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!!!");
}
+ 7
which language?
https://www.sololearn.com/discuss/333866/?ref=app
+ 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/
+ 2
Sorry, HTML
+ 2
<div id="d1" style="display: none">The text</div>
<button onclick="document.getElementById('d1').style. display = 'block'">click me to see text </button>
+ 1
here is code if you want explanation tell me
https://code.sololearn.com/Wbn77J2Yx8fp/?ref=app
0
ok