Skip to content
← Back to Community
How to make interaction in HTML,CSS,JS
Profile icon
Trex10

How do I make it so that if a user clicks something on the HTML page it changes something on there? I know I can do a function event listener thingy in the JS. But it than just changes it to a blank page with whatever I want. Is there a way to make it so when I put something on the screen its on the same backgound and text?

Voters
Profile icon
Trex10
Comments
hotnewtop
Profile icon
[deleted]

Invite me to the repl I’ll show you

Profile icon
Trex10

@IL2PG
Ok, did you get the invite?

Profile icon
[deleted]

@Trex10 no. Try using invite link

Profile icon
[deleted]

@Trex10 I’m in

Profile icon
Coder100

Html:

<p id="demo">lol</p> <button id="button">Clikc </button>

js:

document.getElementById("button").addEventListener("click", function() { document.getElementById("demo").innerHTML = "Paragraph changed!"; });

perhaps you need to take the time to properly learn js?

Profile icon
Trex10

@Coder100
IL2PG is helping me that wasn't as it started

Profile icon
Trex10

@Coder100
I first looked at @DavidShen2 s link and put that there but than @IL2PG Started helping me and that stayed there.

Profile icon
DavidShen2

You can use javascript to change the HTML.
More info here: https://www.w3schools.com/jsref/prop_html_innerhtml.asp