Jump to content

jquery slidedown a hidden div


Pain

Recommended Posts

Hi there.

 

I want to make a sliding div which is hidden.

 

Lets say there is a document and a button within a document. A new div slides down as soon as the button is clicked. I've tried using css visibility: hidden and then jquery:

 

$(document).ready(function(){
$(".in_line2").click(function(){
$(".message_box").css("visibility", "visible");
$(".message_box").slideDown("slow");
});
});

 

however what happens is the box appears instantly and that's it, no sliding effect.

Link to comment
Share on other sites

jQuery slide down uses display not visibility. I have created an example for your use.

 

<style>
    .message_box {
      display:none;
    }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>

<script>
$(document).ready(function(){

   $(".in_line2").click(function() {
      $(".message_box").slideDown("slow");   
   });
});

</script>

<span class="in_line2">Click Me</span>
<div class="message_box">And I'll slide down<>

 

It's been tested to work. So everything should be fine.

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.