I am trying to put a read more button into all my pages but it's not quite working properly. It shows all the text initially, then when it's clicked once it works properly. Can someone please tell me what i'm doing wrong? I'd also like to know how to format the look of the button too please.
The page is here - https://ffe-dev.flowersforeveryone.co.za/sea-point-flower-delivery/
I am using the following code in HTML -
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 = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
.moretext{
display: none;
}
<div class = "textcontainer">
<br>
<br>
<H3> SHOW YOUR LOVE WITH FLOWERS </H3>
<p>
<br>
When you send flowers, it’s a deeply personal gesture of affection, we realise this well. Receiving a gift of flowers is intensely memorable to someone, because it makes them feel very special and loved. Flowers For Everyone gives you the assurance that we get it right, every time.
<br>
<br>
<span id="dots"></span><span id="more">
We have a striking range of luxury flower bouquets freshly cut & hand-delivered across the Western Cape province; from Sea Point with its breathtaking sea views and trendy restaurants, to the Cape winelands and beyond, we put smiles to faces.
<br>
<br>
</span></p>
</div>
<button onclick="myFunction()" id="myBtn">More...</button>
` is not a substitute for margins! – Quentin Aug 20 '19 at 15:14
` is not a substitute for `
`. If you have multiple paragraphs then write multiple paragraphs. Don't write one paragraph with lots of double line beaks in it.
– Quentin Aug 20 '19 at 15:16