I'm working on an html tag called "loginBox" (
<loginBox> ... </loginBox>
) that is initially hidden with display:none
. When a user selects an option, I want it to smoothly slide down instead of just appearing and disappearing. How can I achieve this effect by first declaring it as display:block
for it to fully appear?
The CSS
loginBox {
background:#424242;
font-size:16px;
color:#DEDEDE;
line-height:25px;
width:335px;
padding:15px;
padding-left:50px;
margin-top: 9px;
padding-bottom:25px;
overflow-y:hidden;
display:block;
}
.collapse {
display:none;
}
The Javascript/jQuery
if ($(this).hasClass('selected')) { // the element that needs to be selected
$("loginBox").addClass('collapse')
} else { /*select*/
$("loginBox").removeClass("collapse");
}