I'm pretty new at this. So far I've managed to get my text to fade in when I click a button using CSS, but then the style stays there and I can't get it to reset the opacity back to zero on when clicking a new button. I don't want to use pure Javascript to do it, as I want to expand on the CSS aspect. I hope this makes sense, but if anyone can help me make it so the text fades in every time I click a button, that would be amazing.
Even better, if you can show me how to make the CSS fade it out again, that would be super amazing. Many thanks.
This is a link to how it currently works. http://infinitedv.co.uk/test01/experiment01.html
function text1() {
textbox.style.opacity = 1;
textbox.style.transition = "opacity 1.6s";
document.getElementById("textbox").innerHTML =
"This is a test of My Amazing New Javascript skills! This is a test of My Amazing New Jazascript skills! This is a test of My Amazing New Jazascript skills! This is a test of My Amazing New Jazascript skills! This is a test of My Amazing New Jazascript skills! This is a test of My Amazing New Jazascript skills! This is a test of My Amazing New Jazascript skills! ";
};
function text2() {
textbox.style.opacity = 1;
textbox.style.transition = "opacity 1.6s";
document.getElementById("textbox").innerHTML = "Even more evidence of my amazing new javascript skills! Would you like to know the time and date? No problem:" + "<br><br>" + Date();
};
#textbox {
width: 400px;
opacity: 0;
}
#wrapper {
margin: auto;
width: 500px;
}
<div id="wrapper">
<h1>Will's Amazing javascript experience!</h1>
<button onclick="text1()" type="Button 1">Button1</button>
<button onclick="text2()" type="Button 2">Button2</button>
<br />
<p id="textbox">Text will Magically appear here!</p>
</div>
setTimeoutcalls but just letting thetransitionproperty of CSS do its work