Overwriting entire html page when calling function


I want my paragraph tags to remain where they are on the page after clicking my button. When I click it now, it erases everything on the page and only document.writes what the functions says.
How can I pretend the page from refreshing?

<!DOCTYPE html>
	<title>I don't know</title>

	<p>Do you want to play Rock Paper Scissors?</p>

	<button name="data" type="button" onclick="yes()">Yes</button>
	<input type="button" onclick="no()" value="No">


		function yes() {




I think you might be posting in the wrong place. This is JavaScript, but you posted HTML. :stuck_out_tongue:


add a <p> tag inside <body> give it an id
<p id="demo"></p>

and inside the yes function instead of



document.getElementById("demo").innerHTML = "Awesome";


Oops sorry :frowning: This is my first time posting
Edit: Actually, the lesson I'm trying to do is in javascript lessons, and I have some js code in my html.
I didn't know if I needed to code using html or js to fix my problem, so I just put it here


Ohhh okay, I see now. Thanks a lot :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.