In the following code, the text within the <span class="more">
tag is not hidden by default. I have to click the button to hide the text.
How can I achieve that the text is hidden per default when the page is loaded?
var i = 0;
function read() {
if (!i) {
document.getElementById("more").style.display = "inline";
document.getElementById("dot").style.display = "none";
document.getElementById("read").innerHTML = "Read less";
i = 1;
} else {
document.getElementById("more").style.display = "none";
document.getElementById("dot").style.display = "inline";
document.getElementById("read").innerHTML = "Read more";
i = 0;
}
}
<p class="text-left">
There are a majority of people use the iPhone. Solutions know iPhone is the
powerful smartphone device today and available to us.
<span id="dot">...</span>
<span id="more">
We have expert mobile app developer, fortunately, Solutions is capable
to develop the best app for your business. Our expert high optimized and
suitable apps and games for your iPhone with high technical expertise
and provide maximum functionality to the device while fulfilling your
needs in a professional manner with attractive looks.
</span>
</p>
<button type="button" id="read" onclick="read()">Read more></button>