Я студент по программированию, я разработал это программирование, которое добавляет rain.text с сервера, который говорит, что «дождь в Испании остается в основном на равнине».Но я бы хотел, чтобы программа удаляла текст дождя, когда пользователь снова нажимает кнопку, а затем снова добавляю rain.txt, если пользователь нажимает кнопку еще раз.Любая помощь с тем, как подойти к этому, пожалуйста?
<html>
<head>
<style>
#hidereveal
{
margin:auto;
width:90%;
height:auto;
border: 1px black solid;
text-align:center;
}
p
{
text-align:center;
}
</style>
</head>
<body>
<div id="hidereveal">
<p>this is a test, when you click the button and ajax will add in more data
from the server<button type="button" onclick="loadDoc()">Click to read
more</button></p>
</div>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("hidereveal").innerHTML += this.responseText;
}
};
xhttp.open("GET", "rain.txt", true);
xhttp.send();
}
</script>
</body>
</html>