jQuery accordion - style="display:none; - stops javascript

simple jquery accordion
accordion jquery examples with source code
jquery ui accordion collapse all
jquery accordion active index
jquery accordion plugin
jquery collapse
accordion jquery codepen
onclick accordion jquery

I'm using an accordion style html code

<div class="accordion-link">Link</div>
<div class="accordion-panel" style="display:none;">content</div>

with this jQuery script

$(function(){
    $('.blog .accordion-link').click(function(){
        if(!$(this).hasClass('accordion-on'))
        $('.blog .accordion-link').removeClass('accordion-on');
        $(this).toggleClass('accordion-on');
        $(this).next(".accordion-panel").slideToggle().siblings(".accordion-panel:visible").slideToggle();
    })
});

In the first accordion tab I'm using a fotorama slideshow.

The problem I'm facing is, that the 'style="display:none;' breaks/stops the execution of the slideshow. How can use the slideshow after toggling the accordion?

Regards Peter

Try removing the inline style from there, and add a parent <div> which wraps all that, and then control the slideToggle from there, not on the accordion itself.

<div class="acc">
  <div class="accordion-link">Link</div>
  <div class="accordion-panel" style="display:none;">content</div>
</div>

Also I'm not sure what your if is for but you can just use toggleClass()

jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly  Accordion Widget in jQueryUI is a jQuery based expandable and collapsible content holder that is broken into sections and probably looks like tabs. jQueryUI provides accordion () method to achieve this.

Hail mary guess

Try:

<div class="accordion-panel"style="visibility:hidden;">content</div>

I think the plugin is trying to manipulate that css.

Do you have a demo I could look at? I might be able to give a better answer.

HTML Markup. To begin with, let's put the following div with the id accordion that will contain the entire accordion's content. jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.

$(function(){
    $('.accordion-link').click(function(){
        if(!$(this).hasClass('accordion-on'))
        $('.accordion-link').removeClass('accordion-on');
        $(this).toggleClass('accordion-on');
        $(this).next(".accordion-panel").slideToggle().siblings(".accordion-panel:visible").slideToggle();
    })
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="accordion-link">Link</div>
<div class="accordion-panel" style="display:none;">content</div>
<div class="accordion-link">Link2</div>
<div class="accordion-panel" style="display:none;">content2</div>
<div class="accordion-link">Link3</div>
<div class="accordion-panel" style="display:none;">content3</div>

DEMO: http://so.lucafilosofi.com/jquery-ui-accordion-css/. updated to latest jQuery version 10. you don't need to have all that code! you have copied the jquery  Related jQuery Plugins. Accordion Carousel With jQuery And CSS Grid Layout - Blue-Slider. Responsive Accordion Slider With jQuery And CSS3. Interactive Banner Slider Plugin With jQuery - splits-slider. Smooth jQuery Based Accordion-style Image Slider - Accordion.js. Responsive Diagonal Slider Plugin With jQuery And CSS3 - Skewed Slider

I removed the inline style "display:none" and added this line of code in jQuery script

$('.accordion-panel').css('display','none');

This helps fotorama initialize and start - but with the wrong image size.

Adding this line of code to the click(function)

$(window).trigger('resize');

resolves the problem. Now it works.

Hello I have installed jqueryUI with default theme all work fine I need to style accordion with 100% custom icon, color, etc .. how to "isolate"  Creating accordion by the jQuery plugin is merely the matter of including jQuery UI library and calling an accordion in JavaScript section where it is associated to an element like div, paragraph etc. that will act as an accordion. In this tutorial, I will explore different options provided by jQuery UI accordion plugin as well.

Accordions are useful when you want to toggle between hiding and showing large Style the buttons that are used to open and close the accordion panel */ jQuery Make sure either to run on DOM ready or at the bottom of the page. (function($) { var allPanels = $('.accordion > dd').hide(); $('.accordion > dt >

It was released in January 2006 at BarCamp NYC by John Resig. Used by over 55% of the 10,000 most visited websites, jQuery is the most popular JavaScript. The accordion widget uses the jQuery UI CSS framework to style its look and feel. If accordion specific styling is needed, the following CSS class names can be used for overrides or as keys for the classes option: ui-accordion: The outer container of the accordion. ui-accordion-header: The headers of the accordion.

jQuery Make sure either to run on DOM ready or at the bottom of the page. (​function($) { var allPanels = $('.accordion > dd').hide();  jQuery UI Accordion CSS. you don't need to have all that code! you have copied the jquery example that explane how jquery create the full accordion widget!

Comments
  • a lack of { } after your if... statement is a classic cause of problems with JS code. Did you intend for the lines after it to be conditional, and if so, which ones? Even if the behavior is "correct", it may be accidentally so...