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. Feedback
  3. hide expand collapse row text after it's been pressed

hide expand collapse row text after it's been pressed

Scheduled Pinned Locked Moved Feedback
4 Posts 2 Posters 51 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.
  • A Offline
    A Offline
    alasdair17
    wrote on last edited by
    #1

    hey, is there a way to hide the expand collapse row text after it's been clicked?

    Link here: https://katie.alasdairdimmick.com/the-path/

    I'd like the 'continue reading' text to vanish after it's been clicked.

    I tried asking chatgpt and this was the result:

    <script>
    jQuery(document).ready(function($) {
    // Target the "Continue reading" link
    $('.expand-link-clicked').on('click', function() {
    // Hide the link when clicked
    $(this).fadeOut();
    });
    });
    </script>

    I tried changing the $ to jQuery too but didn't work either.

    Thanks.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alasdair17
      wrote on last edited by alasdair17
      #2

      I managed to get it working. If anyone is interested here is the code from chatgpt:

      <script>
        jQuery(function($) {
          // Function to initialize the expand/collapse functionality
          function initExpandCollapse() {
            // Monitor changes to the "Continue reading" link
            const observer = new MutationObserver(function(mutations) {
              mutations.forEach(function(mutation) {
                // Check if the class "expand-link-clicked" is added to the link
                if (mutation.type === 'attributes' && $(mutation.target).hasClass('expand-link-clicked')) {
                  // Once class is added, fade out the link with a small delay
                  $(mutation.target).fadeOut(300);  // Add a duration here for smoother fade-out
                }
              });
            });
      
            // Select the "Continue reading" link
            $('a[href="#expandrow"]').each(function() {
              // Start observing for changes to the link's attributes (class)
              observer.observe(this, {
                attributes: true  // We are only interested in changes to the link's class
              });
            });
      
            // Add click event to the "Continue reading" link
            $('a[href="#expandrow"]').on('click', function(e) {
              e.preventDefault();  // Prevent default link action
      
              var targetRow = $($(this).attr('href'));  // Get the target element for expansion
              if (targetRow.length) {
                // Trigger the expansion smoothly with animation timing
                targetRow.animate({ height: 'auto' }, 400);  // Expand smoothly
                targetRow.trigger('click');  // Trigger the expansion of the target row
              }
            });
          }
      
          // Initialize the function when the page is loaded or revisited
          initExpandCollapse();  // Initialize the functionality when the page first loads
      
          // Use a simple interval check to make sure the functionality works after navigation
          setInterval(function() {
            // Make sure the "Continue reading" functionality is re-bound even after navigating between pages
            initExpandCollapse();
          }, 500);  // Check every 500ms if it's necessary
        });
      </script>
      
      
      1 Reply Last reply
      0
      • arminunruhA Offline
        arminunruhA Offline
        arminunruh
        Global Moderator
        wrote on last edited by arminunruh
        #3

        instead of:

            // Use a simple interval check to make sure the functionality works after navigation
            setInterval(function() {
              // Make sure the "Continue reading" functionality is re-bound even after navigating between pages
              initExpandCollapse();
            }, 500);  // Check every 500ms if it's necessary
        

        you can do

            // make sure the functionality works after navigation
            window.laytheme.on('newpageshown', function(){
              // Make sure the "Continue reading" functionality is re-bound even after navigating between pages
              initExpandCollapse();
            })
        
        A 1 Reply Last reply
        1
        • arminunruhA arminunruh

          instead of:

              // Use a simple interval check to make sure the functionality works after navigation
              setInterval(function() {
                // Make sure the "Continue reading" functionality is re-bound even after navigating between pages
                initExpandCollapse();
              }, 500);  // Check every 500ms if it's necessary
          

          you can do

              // make sure the functionality works after navigation
              window.laytheme.on('newpageshown', function(){
                // Make sure the "Continue reading" functionality is re-bound even after navigating between pages
                initExpandCollapse();
              })
          
          A Offline
          A Offline
          alasdair17
          wrote on last edited by
          #4

          @arminunruh nice, thanks!

          1 Reply Last reply
          0
          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