JavaScript How to make element slide down from display:none? make element slide in

I have an html tag, "loginBox" (<loginBox> ... </loginBox>) that drops down when a user selects an option. However, before that it is hidden with display:none. How can I make it drop down, considering that before I do that I have to declare it display:block and it will fully appear? The present code has it just appear and disappear, and it would look better with a slide-down effect.

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

($(this).hasClass('selected')) {  // the element that needs to be selected
          $("loginBox").addClass('collapse')
         } else { /*select*/ 
          $("loginBox").removeClass("collapse"); 
        }
Answer:1

Is this what you want?

FIDDLE

$(document).ready(function(){
    $("loginbox").addClass("collapse");
    $(":checkbox").change(function(){
        if($(this).is(":checked")){
        //$("loginBox").removeClass("collapse"); 
        $("loginBox").slideDown(); 
        }
        else
        {
            //$("loginBox").addClass("collapse"); 
            $("loginBox").slideUp(); 
        }
    });
});
Answer:2

You can do this without jquery by making use of css transitions transition: all 0.5s ease-in-out;

See this DEMO

Answer:3

I am using revision 71. How you can see on images, i can escape some objects in vision, when i am using transparent material. Sorry, i don't know how to explain my problem better. renderer....

I am using revision 71. How you can see on images, i can escape some objects in vision, when i am using transparent material. Sorry, i don't know how to explain my problem better. renderer....

How can I remove an HTML tag, depending on what the content is? For example: <header> <h3> <a href="/category/people/">People</a> <a href="/category/hide/">...

How can I remove an HTML tag, depending on what the content is? For example: <header> <h3> <a href="/category/people/">People</a> <a href="/category/hide/">...

I have a some data that I am using to create many charts. I am using d3.nest to create a key so I can organize my charts by date. Everything seems to be working except that I cannot get the pie ...

I have a some data that I am using to create many charts. I am using d3.nest to create a key so I can organize my charts by date. Everything seems to be working except that I cannot get the pie ...

  1. iterate over objects javascript
  2. iterate over objects js
  3. iterate over objects python
  4. iterate over objects typescript
  5. iterate over objects in array javascript
  6. iterate over objects java
  7. iterate over objects
  8. iterate over objects es6
  9. iterate over objects angular
  10. iterate over objects in list python
  11. iterate over objects powershell
  12. iterate over objects c#
  13. iterate over objects hashmap
  14. iterate over nested objects javascript
  15. iterate over json objects
  16. django iterate over objects
  17. iterate over jquery objects
  18. jq iterate over objects
  19. iterate over json objects python
  20. python iterate over objects in a class

I asked this question before and i had a response telling me to add a service but it doesn't work.I want to access to a variable from a controller ($scope) in an external function you can see part of ...

I asked this question before and i had a response telling me to add a service but it doesn't work.I want to access to a variable from a controller ($scope) in an external function you can see part of ...

  1. access object from another class java
  2. access object from array javascript
  3. access object from another class c#
  4. access object from array
  5. access object from another form c#
  6. access object from another thread c#
  7. access object from array php
  8. access object from json
  9. access object from js
  10. access object from php
  11. access object from class
  12. access object from form
  13. access object in javascript
  14. access object in python
  15. access object in jquery
  16. access object in list python
  17. access object in arraylist java
  18. access object with variable javascript
  19. access object in java
  20. access object in array js