Jump to content

Help needed with show / hide text


Zola
Go to solution Solved by Zola,

Recommended Posts

Hi 

 

I have a lot of text in a few sections for one page. I want to use a show / hide to expand and close the extended detailed if the user wants to read more.

 

At the moment I have a solution, the open link appears in the middle of the text where I want it, but when the user clicks to extend the text, the link stays in the same place..... I would like it to appear at the bottom of the extended text.

 

I am not sure how to change this. Do you have any ideas?

 

Any help would be much appreciated.

 

Here is my current code

 

 

<h1 id="headline">Headliner</h1>
 
<p>opening paragraphs....</p>
 
 <a href="" class="readmore">Read More..</a>
 
<div class="hiddenContent">
 
           <p>Extended content when the user clicks.</p>    
  
  </div>   <!-- /hiddenContent-->    
     
 <script>
      $('.hiddenContent').hide();
      $('.readmore').click(function () {
        $('.hiddenContent').slideToggle('slow', function(){
          $('.readmore').text($(this).is(':visible')? 'Close' : 'Read More..');
        })
        return false;
      });
    </script>
                 

Link to comment
Share on other sites

  • Solution
Got sorted with this!

 


   <script>
 $(document).ready(function() {
$('.hidden_software').hide().before('<a href="#" id="open-hidden_software" class="link">Read More ↓</a>');
$('.hidden_software').append('<a href="#" id="close-hidden_software" class="link">Close ↑</a>');
$('a#open-hidden_software').click(function() {
$('.hidden_software').slideDown(1000);
$('#open-hidden_software').fadeOut(500);
return false;
});
$('a#close-hidden_software').click(function() {
$('.hidden_software').slideUp(1000);
$('#open-hidden_software').fadeIn(500)
return false;
});
 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.