0

I have one div that slides up after clicking on a button/link, but it seems to move down slightly first and then backup which makes it look a bit strange. When clicking the button/link it should just slide upwards without moving down first.

here is the jquery code that i am using:

 $(document).ready(function($){
    $('#hide_cookie').click(function() {
      $('.cookie').slideUp('slow', function() {
        // Animation complete.
      });
    });
});

this is the html code:

<div class="cookie">
    <div class="container_12">
        <span>header here</span>
        <p>tex there</p>
    </div>
    <div class="button">
       <a href="#" id="hide_cookie" class="read-more">Continue</a>
    </div>
</div>

any suggestions?

AndrewS
  • 1,555
  • 4
  • 20
  • 32

2 Answers2

1

The element needs to have a height property. Otherwise jQuery wont do a smooth animation.

Read more

Basic jQuery slideUp and slideDown driving me mad!

Community
  • 1
  • 1
Johan Davidsson
  • 2,852
  • 2
  • 19
  • 27
0

try event.preventDefault()

here

 $('#hide_cookie').click(function(e) {
  e.preventDefault();
  $('.cookie').slideUp('slow', function() {
    // Animation complete.
  });
});
bipen
  • 36,319
  • 9
  • 49
  • 62