简体   繁体   中英

Slide up div on click

I want to create an effect similar to the bbc website where the user will click on the title and then a snippet of content will pop up: http://www.bbc.co.uk/

i have looked all over the place and found this snippet

$('.grabPromo').click(function(e){
$('.slideUp').slideToggle();
});

JSFIDDLE

I cannot get it to the opposite though? i want the text to slideup rather then down. Any help would be appreciated. if someone can point me in the right direction either using css or Jquery i would be grateful.

I am using it for the captions on the Slick Carousel in case that helps at all.

What i want before Click: BBC悬停之前

What i want it to do on Click: BBC悬停

You can use the callback:

$('.grabPromo').click(function(e){ 
    $('.slideUp').slideDown(300 , function() {
         $(this).slideUp(300);
    });
});

See the fiddle: http://jsfiddle.net/Sd8rh/858/

In this fiddle you have an example with delay.

Good luck

You can use jquery UI library

$('.grabPromo').click(function(e){
  $('.slideUp').toggle("slide", { direction: 'up' });
});

For more information https://jqueryui.com/effect/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM