The New Gallery
New Coder
Hi, I'm trying to do a Read More/Read Less style button with a translation of the text on our webpage: https://thenewgallery.org/The-New-New-Society-Ang-Bagong-Bagong-Lipunan-Cris-Mora
The button works, however the text within the button that reads "中文翻译 Chinese Translation" does not load unless you click on the button first. I would like this text to show automatically when you load the page, instead of an empty button. I've been trouble shooting this and I have been unable to figure it out. Below is my HTML code and CSS code for the button.
The button works, however the text within the button that reads "中文翻译 Chinese Translation" does not load unless you click on the button first. I would like this text to show automatically when you load the page, instead of an empty button. I've been trouble shooting this and I have been unable to figure it out. Below is my HTML code and CSS code for the button.
HTML:
<p>中文翻译 Chinese Translation<span id="dots"
style="display: inline;">...</span><br><br>
<span id="more" style="display: none;">
<br><br>
CHINESE TRANSLATION TEXT GOES HERE
<br><br>
</span></p>
<button onclick="myFunction()" id="myBtn"></button>
<script>
function myFunction() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("more");
var btnText = document.getElementById("myBtn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "中文翻译 Chinese Translation";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "隐藏中文翻译 Hide Chinese Translation";
moreText.style.display = "inline";
}
}
</script>
CSS:
input,
button {
color: rgba(11, 0, 255, 0.81);
font-family: Raleway;
font-size: 14px;
padding: 0;
margin: 0;
border: 0;
background-color: #fff;
}