I am completely new to the world of JavaScript, HTML, and CSS, so I'm feeling a bit lost on how to proceed with this task.
My goal is to create a script that will initially display some text through a specific function. Once that text has been displayed, I want an HTML button (or something similar) to automatically fade in without requiring any user interaction. My assumption is that the button would need to be inserted beforehand and hidden somehow, and then its visibility would be adjusted to achieve the desired fade-in effect. Is this achievable with JavaScript, or are there potentially simpler methods that I should consider? Any guidance you can provide would be greatly appreciated.
Here is the code I have developed thus far:
<!DOCTYPE=HTML>
<html>
<head>
<title>Sandbox</title>
<link rel="stylesheet" href="mainstyle.css">
<script src="main.js"></script>
</head>
<body>
<p id="pid"></p>
<script>
var a = 1;
function dialogue(){
var message = "This message is (hopefully) a successful implementation of JS video game scrolling! <br> <br> Pretty cool, huh? Well, believe it or not, this whole page is a test for a very basic interactive story using HTML/JavaScript! <br> <br> Let's see if we can add some fade-in buttons, shall we? <br> <br> (By the way--you can click anywhere in this window to instantly clear through subsequent text scrolls.)";
if(a <= message.length) {
var txt = message.substring(0,a);
document.getElementById ("pid").innerHTML = txt;
setTimeout("dialogue()",20);
a++;
document.onclick = function(){
a = message.length;
};
}
};
dialogue();
</script>
<button id="button1">Ooh, here's one! Click to see what it does!</button>
</body>
</html>