Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design See More – See Less

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #204507
    fredtheted
    Participant

    I’m trying to add coding in my HTML so that only the first 9 lines of text are shown unless the surfer clicks on “See more”.

    I’m retired but still trying to help a friend update his website. Can some kind person look at this page http://www.go-there.co.uk/attractions/a-blank.phtml and scroll down to the first box and tell me where I’ve gone wrong. Thanks.

    #204508
    Shikkediel
    Participant

    Something like this would require some JavaScript (or less desirably a CSS hack). I don’t see any of that going on? The slider loads the jQuery library already so that would be easiest to use.

    .read-more-content {
    display: none;
    }
    
    $(document).ready(function() {
    
      $('.read-more-show').click(function(e) {
    
          e.preventDefault();
          $('.read-more-content').slideDown();
      });
    
      $('.read-more-hide').click(function(e) {
    
          e.preventDefault();
          $('.read-more-content').slideUp();
      });
    });
    
    #204530
    fredtheted
    Participant

    Hi, Thank you for your kind reply. I’m getting in a right old mess with this. I’ve added the CSS but not sure where to place the $(document).ready(function() { part.

    I originally had both boxes looking fine with the “Show more text” showing as a link at the bottom but once you clicked on read more, the extra text displayed but the show less didn’t work.

    If I clicked “Show more text” on the lower box the top box opened but not the second box.

    http://www.go-there.co.uk/attractions/a-blank.phtml

    I hope you or another member can help.

    #204531
    Shikkediel
    Participant

    I do see some inline script now that was apparently already there – did I miss that or did you maybe also change the HTML, along with adding the new script I posted? It is right below where the new lines were pasted.

    In any case, the code provided (in this forum thread) isn’t quite in the right place as it is in the middle of the document. You can see some of it has been displayed as text. Best thing would be to place in the head section at the top, just before the closing </head> tag. Also, it would need to have some script tags around it defining it as JavaScript – unfortunately I can’t show a good example of that because the forum software will spit it out.

    [script type="text/javascript"]
    
    previous posted code
    
    [/script]
    

    Where the [ and ] brackets should be replaced with < and > (they will get denied if I write the correct characters).

    Hope that helps.

    #204534
    fredtheted
    Participant

    The problem is that I don’t see the <head> </head> on my system as we use block editor based on an individual page such as http://www.go-there.co.uk/attractions/a-blank.phtml

    I have made the two boxes the same now but the show more works fine on the top box but the show less doesn’t. Also if you click on the second (bottom) box it doesn’t work (opens the top box only).

    I can add to the CSS file and I can add <script> </script> to the page along with the text and pictures, but that’s all I can do.

    Can you point me in the right direction and show me a way to achieve what I need by adding to the CSS file, etc.

    Thank you for your assistance and patience.

    #204536
    Shikkediel
    Participant

    Let me investigate, it looks quite different from what I saw yesterday (the inline script definitely wasn’t there before). At the moment it is actually the existing script that is showing the text…

    Pasting the code in the head section would be easiest for overview but it could really be pasted ‘anywhere’ as long as it doesn’t interfere with the existing markup. Putting it right before the ending &lt;/body&gt; tag should also be fine for example. It will not work yet though because the divs now have more generic names than the code was written up for.

    #204537
    Shikkediel
    Participant

    Okay, the code I wrote shouldn’t even be necessary. If ‘uniquename’ is matched in both the &lt;a href= then the existing script should work :

    Problem right now is the ‘ibiza-2’ in the second link. I don’t have any insight how to modify this exactly, it being dependent on the CMS that is used…

    There’s a backgorund typo in the first one by the way.

    #204540
    fredtheted
    Participant

    Hi, I got in a right old fix so I scrapped what I had done and started to use http://codepen.io/Idered/pen/AeBgF?editors=110

    I posted the CSS and used the coding given and at first glance looks ok. http://www.go-there.co.uk/attractions/a-blank.phtml

    However, if you click on the top box it expands and closes ok but if you click on the second box all that happens is that it opens the top box. I want to use about 10 of these boxes per page so I hope you know a way around this.

    Any help would be much appreciated and I promise not to touch anything on the page until you reply.

    #204543
    Shikkediel
    Participant

    That’s the CSS hack I mentioned earlier… I’ve never used that myself before so it will be kind of hard to help with, unless I start reading up a bunch first.

    :-/

    Any chance we could go back to JavaScript? It is the much cleaner solution and it would be a lot easier for myself to put together.

    #204545
    fredtheted
    Participant

    Thanks but I’ll stick at it and ask on the other CSS forum to see if there is any advise. Thanks for your help to date You’re a star.

    #204546
    Shikkediel
    Participant

    Cheers, I’ll keep an eye on the forum in case you change your mind. ;-)

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘Design’ is closed to new topics and replies.