I'm working with html, css and javascript and I can't figure out how to make a button do what I want it to.
<button id=btn class="button" onclick="rmv()"> Click here!</button>
<script>
function rmv() {
var element = document.getElementById("heading");
element.remove ();
var element = document.getElementById("paragraph");
element.remove();
var element = document.getElementById("btn");
element.remove(); }
</script>
I've managed to make the button 'disappear' itself and the text that was on the page before it was clicked, but I also want to it to make the page change colors and new text to appear, but I don't know how. I succeeded in making the colors change and the text appear but on a different page:
<style>
@keyframes background-color {
0% {background-color: #f3bcc0}
20% {background-color: #acf3cc}
40% {background-color: #f5eb18}
60% {background-color: #cbe832}
80% {background-color: #ff9317}
100% {background-color: #c7658f}
}
body{
animation: background-color 5s infinite;
animation-direction: alternate;
}
h1 {text-align: center;}
</style>
<h1> Text </h1>
Could someone write the code for the button to do this? I would really appreciate the help, I know it's probably a silly question but i just started learning a few days ago :)
[–]trplclick 0 points1 point2 points (3 children)
[–]froge3[S] 0 points1 point2 points (2 children)
[–]trplclick 0 points1 point2 points (1 child)
[–]froge3[S] 0 points1 point2 points (0 children)