Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. "Read more" button

"Read more" button

Scheduled Pinned Locked Moved General Discussion
buttonreadmore
7 Posts 3 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marta
    wrote on last edited by
    #1

    Hi Armin!

    In a page of my site I have a long text and I wish it was fully visible only when you click a "Read more" button.
    I first tried a pair of plug-in (Wp show more, Collapse-O-Matic), but they didn't work because the inclusion of texts in Lay Theme is different from the classic mode of Wordpress themes.
    So I tried to insert a button through the codes, and the only system that seems to work is this:
    https://codepen.io/devkick/pen/soJpy

    HTML and CSS parts work well, but I can't integrate the Js part. I paste the Js code in "Custom <head> content", in a script tag and put "JQuery" instead of "$", but it still does not work.

    Original script:
    $(".readmore").on('click touchstart', function(event) {
    var txt = $(".more-content").is(':visible') ? 'Show more (+)' : 'Less (–)';
    $(this).parent().prev(".more-content").toggleClass("visible");
    $(this).html(txt);
    event.preventDefault();
    });

    My version:
    <script>
    jQuery(".readmore").on('click touchstart', function(event) {
    var txt = jQuery(".more-content").is(':visible') ? 'Show more (+)' : 'Less (–)';
    jQuery(this).parent().prev(".more-content").toggleClass("visible");
    jQuery(this).html(txt);
    event.preventDefault();
    });
    </script>

    My page: http://fabrizioinglese.com/bio-di-prova

    Did I do something wrong?
    Is there another way to insert the button?

    I hope you give me a solution!
    Thanks for the help and for the theme,

    Marta

    1 Reply Last reply
    0
    • arminunruhA Offline
      arminunruhA Offline
      arminunruh
      Global Moderator
      wrote on last edited by
      #2

      Hey Marta sorry for my late response. As written here http://laytheme.com/documentation.html#binding-click-events you need to bind clicks a bit differently.

      <script>
      jQuery(document).on("click touchstart", ".readmore", function(event) {
      var txt = jQuery(".more-content").is(':visible') ? 'Show more (+)' : 'Less (–)';
      jQuery(this).parent().prev(".more-content").toggleClass("visible");
      jQuery(this).html(txt);
      event.preventDefault();
      });
      </script>
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marta
        wrote on last edited by
        #3

        Don't worry!

        I didn't write the code correctly.
        Thank you very much, now it works perfectly!

        Merry Christmas Armin!

        Marta

        1 Reply Last reply
        0
        • arminunruhA Offline
          arminunruhA Offline
          arminunruh
          Global Moderator
          wrote on last edited by
          #4

          Merry Christmas to you too :)

          C 1 Reply Last reply
          0
          • arminunruhA arminunruh

            Merry Christmas to you too :)

            C Offline
            C Offline
            CesareCesariano
            wrote on last edited by
            #5

            @arminunruh Dear Armin,
            Lay Theme is awesome.

            Is there today a possibility for a "read more" button?
            The Link is invalid, unfortunately.

            Best regards

            1 Reply Last reply
            0
            • arminunruhA Offline
              arminunruhA Offline
              arminunruh
              Global Moderator
              wrote on last edited by
              #6

              yo just use the new "accordion" feature:
              https://www.instagram.com/p/ClBAFnUD-tG/

              C 1 Reply Last reply
              0
              • arminunruhA arminunruh

                yo just use the new "accordion" feature:
                https://www.instagram.com/p/ClBAFnUD-tG/

                C Offline
                C Offline
                CesareCesariano
                wrote on last edited by
                #7

                @arminunruh Best video ever! thx

                1 Reply Last reply
                1
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                I also code custom websites or custom Lay features.
                šŸ’æ Email me here: šŸ’æ
                info@laytheme.com

                Before you post:
                1. When using a WordPress Cache plugin, disable it or clear your cache.
                2. Update Lay Theme and all Lay Theme Addons
                3. Disable all Plugins
                4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

                This often solves issues you might run into

                When you post:
                1. Post a link to where the problem is
                2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
                3. If the problem is difficult to explain, post screenshots / link to a video to explain it
                Online Users
                Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
                laytheme.com
                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Recent
                • Tags
                • Popular
                • Users
                • Search