Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

HTML code x2 on one page


PEA_jaz

Question

Hi Can any one help me understand one only one of my html code blocks work on squarespace?
I have been able to have 2 markdown codes work on the same page, but with the HTML code it does not.

I have two post, same html code, just different content. The code is for a read more/read less button.
One works fine, but when I click on the other read more button it enables the first post to drop down instead of its own (second post).

This is the code below - from some reading i think i need to add an element within the code that allows both or work separately on the same page?

 

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#more {display: none;}
</style>
</head>
<body>

<h2>Read More Read Less Button</h2>
<p>CONTENT<span id="dots"></span><span id="more">eCONTENT.</span></p>
<button onclick="myFunction()" id="myBtn">Read more</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 = "Read more"; 
    moreText.style.display = "none";
  } else {
    dots.style.display = "none";
    btnText.innerHTML = "Read less"; 
    moreText.style.display = "inline";
  }
}
</script>

</body>
</html>

Link to comment
  • Answers 5
  • Created
  • Last Reply

Top Posters For This Question

5 answers to this question

Recommended Posts

  • 0

Hi. Can you share link to page where you added both code? We can check easier

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care - Learn CSS - Custom Popup - Testimonial Slider

I'm Tuan, blogger/owner of a free library for children in Vietnam. Helping the community is a hobby. Contact me via email.

Link to comment
  • 0
8 hours ago, PEA_jaz said:

Hi here is the link - https://olive-shark-cbsx.squarespace.com/config/pages

/config is admin url. See how to find page url.

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care - Learn CSS - Custom Popup - Testimonial Slider

I'm Tuan, blogger/owner of a free library for children in Vietnam. Helping the community is a hobby. Contact me via email.

Link to comment
  • 0
On 6/23/2021 at 10:39 AM, PEA_jaz said:

Sorry the URL page name is:  /about

It looks fine here. Did you solve?

See video. https://www.loom.com/share/e075c735437347058a3747af07b87c39

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care - Learn CSS - Custom Popup - Testimonial Slider

I'm Tuan, blogger/owner of a free library for children in Vietnam. Helping the community is a hobby. Contact me via email.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...