-1

here i have this code which i manage to get what i want but its working only first run idk y may if u can just help me..... demo: http://tryitnow.net16.net/

Html:

<a id="login" href="javascript:void(0);"> Login </a>

Css:

.User-Login {  
visibility:hidden;
position:absolute;
left:1150px;
  top:90px;
background:black;
 -webkit-transition:  height 1s ease;
transition: height 1s ease; 
overflow:hidden;
height:10px;
} 
.box-change {   
height: 250px;  
}
.box-colap {
height:10px;
}

jQuery:

$(function () {
    $("#login").click(function () {
        var visi = $(".User-Login").css('visibility');
        if (visi == "visible") {
            $(".User-Login").toggleClass("box-colap");

            setTimeout(function () {
                $(".User-Login").css('visibility', 'hidden');
            }, 2000);
        } else {
            $(".User-Login").css('visibility', 'visible');
            $(".User-Login").toggleClass("box-change");
        }
    });
});
4

1 回答 1

0

try using this instead...

$(document).ready(function () {
    $('#login').click(function () {
        if($('.User-Login').is(':hidden') {
             $('.User-Login').slideDown();
        } else {
             $('.User-Login').slideUp();
        }
    });
});

when you click the login link it will check if the login box is hidden, if it is then slide it down, otherwise slide it up

于 2013-09-28T18:28:10.460 回答