I'm familiar with using ID's to help display your JavaScript string text onto your HTML webpage like so:
<html>
<body>
<button onClick = "display()">Press Me</button>
<p id = "text"></p>
<script>
function display() {
var string = "hello";
var message = document.getElementById("text");
message.innerHTML = string;
}
</script>
</body>
</html>
But what if I wanted to display "hello" multiple times by the press of the button? I don't want to keep adding id's the same way I did "text" to appear. Is there anyway I could simply print out the text once you press the button for however many times you'd like in vanilla JavaScript?
Also, I am aware of "repeat()" but that's not what I'm looking for.
message.innerHTML = string;, I would do like:message.textContent += string+'<br />';. I just used.textContentso HTML parsing is not an issue. It's the+=that you need.