Here, everything is working just fine. I only need my button tag to call the function which displays a random number on the p tag in DOM and not me refreshing the page all the time.[Here is my HTML]And here is my script(https://phpout.com/wp-content/uploads/2023/05/qtODL-jpg.webp)
I tried using the click
Also tried the inline method on my HTML but it’s ignoring the call.
2
Answers
Make a function in your script
Also, add
onclick="makerandom()"
into your button in HTMLAnd add your script to tour html using the
<script>
tagYou have a couple of tings you are missing before your code works. If I have to answer your question how do you get your button to call a function, then you need to go through some steps.
button
tag. eg.<button id="click" onclick="randnum()">Play</button>