How to make interaction in HTML,CSS,JS
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
Coder100 (17018)
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?
Trex10 (7)
@Coder100
IL2PG is helping me that wasn't as it started
Trex10 (7)
@Coder100
I first looked at @DavidShen2 s link and put that there but than @IL2PG Started helping me and that stayed there.
DavidShen2 (60)
You can use javascript to change the HTML.
More info here: https://www.w3schools.com/jsref/prop_html_innerhtml.asp
Invite me to the repl I’ll show you
@IL2PG
Ok, did you get the invite?
@Trex10 no. Try using invite link
@Trex10 I’m in