0

I'm using jQuery to extend a div to show more information (which is in a div). However, when I click the "show more" link, how can I make it so it'll extend the div as well?

Here's a preview of my project: http://i55.tinypic.com/2uzrtat.png

Notice the "Solo" box. How can I extend it to the bottom if the "see more" link is clicked, and vice-versa?

-- My Code --

$(document).ready(function() {
  $('#slickbox').hide();
 
  $('#slick-toggle').click(function() {
    $('#slickbox').toggle(300);
    $('.column').animate({height:1000+'px'});
  });
});

5 Answers 5

2

Edit:

$('#seemore').toggle(
  function(){
      $('#solo').animate({height:700+'px'});
      $(this).html('See Less');
      },
  function(){
      $('#solo').animate({height:500+'px'});
      $(this).html('See More >>');
   });

switch 700 to whatever you want the height of the Solo box to be and 500 to whatever the original height is

See a working Example: http://jsfiddle.net/G9z37/4/

Sign up to request clarification or add additional context in comments.

5 Comments

Exactly what I'm looking for. However, when I close the div, the height still remains 700px+
sorry I was too lazy to change the div names
@Ima Okay, now my problem. I have multiple "hidden" divs, which, when I click the "see more" link, I need to extend. However, I'm noticing that if I have more than one #solo, then it will only affect one of them, not all of them.
thats because #solo is an id. if you want all of them to be affected change it to a classname i.e .solo
Perfect! I just need help with one more thing (sorry, I'm not good with jQuery). I need, so when the expand link is clicked, the text of it will change to something like "See Less". How could I do this?
0

I'm assuming you want a collapsible div (hidden by default, then expand on click). If that is true, look into the Accordion extension in the JQuery UI plugins, found at http://jqueryui.com/demos/accordion/. It's relatively straightforward to implement, too. If this isn't what you're after, please say so.

Comments

0

You could use the jquery toggle API

Comments

0

If you are looking to restore it back to the original height, you will probably want to store the original height with .data(), and revert back to it when toggled off.

See http://jsfiddle.net/S8yuG/

Comments

0

I'm not completely sure what you're asking, but if you want to change the height of a div, jQuery has a height function.

$("#solo").height(200);  // or whatever you need

Is this what you wanted?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.