How to create renewable button js | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to create renewable button js

I need to create button that shows random non-fraction number when clicked. And it mustn't to disappear after click (work lots of times)

23rd Jun 2017, 8:18 PM
Sasha Smagliy
Sasha Smagliy - avatar
3 Answers
+ 2
Try this: HTML <button onclick="myFunc()"></button> <p id="num"></p> JavaScript function myFunc(){ randNum = Math.floor(Math.random()*100); document.getElementById("num").innerHTML = randNum;
23rd Jun 2017, 8:24 PM
Maart
Maart - avatar
+ 1
Just let me know if you'd like some explanation of it or if you get any errors. It's most important that you understand what's happening in the code!
23rd Jun 2017, 8:26 PM
Maart
Maart - avatar
23rd Jun 2017, 8:34 PM
Ренат Мухаметшин
Ренат Мухаметшин - avatar