JavaScript Foundation 5 Accordion - Transition Speed?

I am using Foundation 5 Accordions on a Website. They work but I want to change the transition speed. Currently when you click they instantly hide one and show the other. I would prefer they transition vs instantly appearing.

I tried CSS but it didn't work:

.accordion dd > a{ 
   transition: all .5s;
}

Note: I am omitted vendor prefixes.

How do I get these to transition smoothly?

If I can do it with pure CSS this is preferred, otherwise JS will work but I am unsure how?

Answer:1

Lynda, I appreciated your code, in foundation 5, the panel stays visible after the second closing. Seems to be caused by jQuery adding style attributes from sliding. I edited it to fix the issue.

$(".accordion").on("click", "dd", function (event) {
        if($(this).hasClass('active')){
            $("dd.active").removeClass('active').find(".content").slideUp("fast");    
        }
        else {
            $("dd.active").removeClass('active').find(".content").slideUp("fast");
            $(this).addClass('active').find(".content").slideToggle("fast");    
        }
});
Answer:2

As it turns out JS is the way to do this:

$(function() {
 $(".accordion").on("click", "dd:not(.active)", function (event) {
   $("dd.active").removeClass('active').find(".content").slideUp("fast");
   $(this).addClass('active').find(".content").slideToggle("fast");
 });
});
Answer:3

You can use this structure:

$(function() {
  $(".accordion").on("click", "dd", function (event) {

   $("div.active").slideUp(100).removeClass('.active');
       $(this).find(".content").slideDown(100).addClass('active');

 })
});

Its work correctly.

Answer:4

I am new to jquery, am working on small table based game here i have to find the neighboring elements around an TD in a table . EX: 1 2 3 4 5 6 7 8 9 there are three rows in a table , if i ...

I am new to jquery, am working on small table based game here i have to find the neighboring elements around an TD in a table . EX: 1 2 3 4 5 6 7 8 9 there are three rows in a table , if i ...

I've 2 dialog forms Add region and Add country. There are <select> options in each modal form. There can be select options which are repeated in each modal form, so I'm putting those in a class ...

I've 2 dialog forms Add region and Add country. There are <select> options in each modal form. There can be select options which are repeated in each modal form, so I'm putting those in a class ...

  1. selected option jquery
  2. selected option javascript
  3. selected option css
  4. selected option text jquery
  5. selected option angular
  6. selected option value javascript
  7. selected option attribute jquery
  8. selected option value jquery
  9. selected option php
  10. selected option data attribute jquery
  11. selected option js
  12. selected option react
  13. selected option color change css
  14. selected option vuejs
  15. selected option in angular 6
  16. selected option text javascript
  17. selected option laravel
  18. selected option not working
  19. selected option angularjs
  20. selected option in angular 7

I am trying to resize the SVGs in dc.js. In the NASDAQ example in the main page itself. When I change the width/height, it cuts of the svg instead of resizing it. For example, changing width and ...

I am trying to resize the SVGs in dc.js. In the NASDAQ example in the main page itself. When I change the width/height, it cuts of the svg instead of resizing it. For example, changing width and ...

  1. resize js event
  2. resize js jquery
  3. resize js window
  4. resize jscrollpane
  5. resize js library
  6. resize jscrollpane jtable
  7. resize jscrollpane dynamically
  8. resize json
  9. js resize canvas
  10. resize js performance
  11. resize js document

I have a form which uses html and javascript to submit data into a table of an SQL database. So I want to submit what is typed from the user to a local SQLite database that is inside his device. I am ...

I have a form which uses html and javascript to submit data into a table of an SQL database. So I want to submit what is typed from the user to a local SQLite database that is inside his device. I am ...

  1. insert value into table sql
  2. insert value into array
  3. insert value into list python
  4. insert value into string python
  5. insert value into cell vba
  6. insert value into dictionary python
  7. insert value into array python
  8. insert value into array java
  9. insert value into numpy array
  10. insert value into array matlab
  11. insert value into array javascript
  12. insert value into pandas dataframe
  13. insert value into table mysql
  14. insert value into row sql
  15. insert value into temp table
  16. insert values into vector c++
  17. insert value into map c++
  18. insert value into array php
  19. insert value into vector r
  20. insert value into array c++