jQuery accordion section refuses to collapse

In order to achieve the desired outcome, each Section should initially appear in a collapsed state. Panel 0 and 2 start off collapsed, however, panel 1 does not but can be collapsed upon clicking. Additionally, Panel 1 incorporates an iframe that displays live Twitter feed on the site.

See below for code examples:

HTML:

<div class="accordion">
    <div class="testimonials col-md-6 col-lg-6">
        <h1>section 1</h1>
        <p>this is a div</p>
    </div>
    <div class="social col-sm-6 col-md-3 col-lg-3">
        <h1>section 2</h1>
        <a class="twitter-timeline" width="100%" data-chrome="transparent noscrollbar" href="https://twitter.com/xxxxxx" data-widget-id="999999">
            Tweets by @xxxxxx
        </a>
    </div>
    <div class="news col-sm-6 col-md-3 col-lg-3">
        <h1>section 3</h1>
        <p>this is a div</p>
    </div>

 Javascript

 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>

 <script type="text/javascript">
        // <![CDATA[
        var $ = jQuery.noConflict(); $(document).ready(function()
        { 

            $(".accordion").accordion({
                active: false,
                collapsible: true,
                header: "h1"
            });

            //getter variables
            var active = $(".accordion").accordion("option","active");
            var collapsible = $(".accordion").accordion("option","collapsible");
            var header = $(".accordion").accordion("option","header");

            $('.carousel').carousel({ interval: 4000, cycle: true }); 
        }); // ]]>

Answer №1

Consider utilizing the following format:

<h3>Introduction</h3>
<div>
Content 
</div>

The content within the div element is not immediately visible, as a header is required to access it.

Answer №2

I have successfully solved the problem. It turns out that after each header, there is a tag containing the content. In order for the content to display correctly, you must use a block-level element and then manually set the height using the heightStyle variable. If you encounter this issue, make sure that the header's sibling is also a block-level element.

For example:

<div class="accordion">
<div class="testimonials col-md-6 col-lg-6">
    <h1>section 1</h1>
    <p>this is a div</p>
</div>
<div class="social col-sm-6 col-md-3 col-lg-3">
    <h1>section 2</h1>
    <div class="social-wrap">
         <a class="twitter-timeline" width="100%" data-chrome="transparent noscrollbar" href="https://twitter.com/xxxxxx" data-widget-id="999999">
        Tweets by @xxxxxx
         </a>
     </div>
</div>
<div class="news col-sm-6 col-md-3 col-lg-3">
    <h1>section 3</h1>
    <p>this is a div</p>
</div>

Answer №3

Unlike other plugins, the jQuery UI accordion does not have the ability to collapse every section at once. It is designed to always display one expanded section. If you need the option to collapse all sections simultaneously, it would be best to opt for creating collapsible regions instead of using the accordion plugin.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Javascript/JQuery to apply pixel values in CSS styling

Recently, I've come across a discrepancy between two different ways of accessing CSS properties in jQuery: <foo>.css('marginTop') (which I always assumed was the standard notation) and <foo>.css('margin-top') (which ...

When floating a heading 4 (h4) and two divs to the left, and a single div to the right,

When floating a h4 and 2 divs to the left, and another div to the right, how can I place a block inside the remaining space that perfectly fills it? The background color of this space should not spread outside. [h4][div][div][remaining space][div] Thank ...

Update the innerHTML content dynamically every 5 seconds with Vue.js

I'm working on a new website and I'd like to spice things up by changing the header text with a random word every 5 seconds. Here's the starting point: const header = document.querySelector('.header') const needs = ['jacket& ...

jQuery user interface Dialog buttons

Is it possible to access the button within a click event handler when creating a dialog with buttons like: buttons: { 'button text': function(){ // do something }, In this ...

Simultaneously sending jQuery.ajax data while submitting a form

I'm facing a bit of a dilemma here. I have a form with multiple fields, including one for entering links. When you input a link and click the add button, the link is added to a link_array using jQuery. My goal is to send this array through the jQuery. ...

What is the best way to access a local variable within a POST method in Node.js?

Below are some of the modules that I have utilized: const mysql = require('mysql'); const express = require('express'); const session = require('express-session'); const path = require('path'); const bodyParser = req ...

Tips for distinguishing the beginning and ending points of wrapped text in the Firefox browser

Within my work, I am utilizing a contentEditable span where I aim to position an element with position: absolute on the same line as the cursor. However, issues arise when text wrapping occurs - causing abnormal behavior at the start and end of wrapped lin ...

Is it possible to use combox to deactivate the buttons?

My goal is to deactivate the button as soon as I select a value from the drop-down list. For example, here's what I have: <select name =""> <option> disable </option> <option> enable </option> </select> <input ...

Troubleshooting the Checkbox Oncheck Functionality

Before checking out the following code snippet, I have a requirement. Whenever a specific checkbox (identified by id cfc1) is clicked, it should not show as checked. I have implemented the onCheck function for this purpose, but I'm struggling to fig ...

Exploring the power of Angular through the use of promises with multiple

I've come across some forum discussions about angular promises in the past, but I'm having trouble implementing them in my current situation. My backend is nodejs/locomotive and frontend is Angular. In the controller code below, I am trying to a ...

How can I make tooltipster display tooltips properly?

I have been struggling to customize tooltips using a library called tooltipster. Here is what I currently have: Head of index.html: <head> <!--TOOLTIP CSS--> <link rel="stylesheet" type="type/css" href="node_modules/tooltipster-master ...

The Elusive Key to Perfect Layouts and its Transformation

Today I discovered the Holy Grail of Layouts while coding, but when I implemented it, the output in browsers was not as expected. The borders were incomplete and strange: Here is the code snippet that caused the issue: #container { border: 10px soli ...

Is it possible to expand the Angular Material Data Table Header Row to align with the width of the row content?

Issue with Angular Material Data Table Layout Link to relevant feature request on GitHub On this StackBlitz demo, the issue of rows bleeding through the header when scrolling to the right and the row lines not expanding past viewport width is evident. Ho ...

Troubleshooting: WordPress post not uploading to custom PHP file - Issue causing ERROR 500

Our website is built using WordPress, and I was tasked with adding a function to our newsletter subscription that sends an email to a specific address based on the selected value in the form. Everything was working perfectly on my local host, but when I tr ...

What is the relationship between font size adjustments and the dimensions of the surrounding parent div element?

I've come across an issue that involves having the following code snippet in the body of an HTML file: html, body { width: 99%; height: 99%; margin: 0px; overflow: hidden; } #container1 { display: flex; gap: 2%; width: 90%; heigh ...

Moving the webpage into the realm of mobile and tablet devices

Over the next few weeks, I will be working on transitioning my website content to have both a mobile and tablet version. During this process, I have some questions: What is the best way to redirect users to the correct site based on their device/browse ...

Discover a method to receive an alert when the mouse exits the inner window along the y-axis

Is there a way to receive an alert if the mouse moves out of the inner window solely in the y-axis? Currently, alerts are triggered when the mouse moves out on both x-axis and y-axis. For example, if the mouse pointer hovers over the address bar coming fro ...

Utilizing Jquery within a Personalized Post Layout

Being a beginner in jquery, I managed to create this functionality - http://jsfiddle.net/t2x9G/3/ Currently working on a Wordpress project and exploring ways to have the dynamic text content pulled from a post rather than hardcoded in the script. $(&apos ...

Utilizing external CSS to style an SVG file within an HTML document

Hello there, I have a collection of SVG files that I need to dynamically modify the fill color of, preferably using CSS. Here is the structure: <div> <svg width="100%" height="100%" viewbox="0 0 64 64" preserveAspectRatio="xMinYMin m ...

Explore bar with search button

I'm facing an issue with the code I have for searching on my website. Currently, when a user fills in their search word and presses enter, it executes the command. However, I would like to only run the search script when the user clicks a button inste ...