Place a <div></div> element within a collapsible accordion container that conceals the content inside the <div>

My accordion is expanding, but the div inside it appears blank instead of displaying its content. Any suggestions on how to fix this? Thank you.

How can I ensure that the div inside the accordion shows its content?

Here is the code: http://jsfiddle.net/6xnt3p8j/1/

JavaScript

$(document).ready(function(){
    $(".accordion2 h3").eq(40).addClass("active");
    $(".accordion2 p").eq(40).show();
    $(".accordion2 h3").click(function(){
        var video = $(".accordion2 h3.active").next().children();
        var src = video.attr("src");
        video.attr("src","");
        video.attr("src",src);

        $(this).next("div").slideToggle("slow")
        .siblings("div:visible").slideUp("slow");
        $(this).toggleClass("active");
        $(this).siblings("h3").removeClass("active");
    });
});

CSS

body {
    margin: 10px auto;
    width: 570px;
    font: 75%/120% Arial, Helvetica, sans-serif;
}

.box {
    display: inline-block;
    padding: 3px;
    margin: 3px auto;
}

.accordion2 {
     min-height:95px;
     height:auto !important;
     height:95px;

}

.accordion2 h3 {
    padding-bottom: 1px;
    margin: 0;
    border-bottom: none;
    cursor: pointer;
    min-height:95px;
    height:auto !important;
    border:1px solid blue;
}
.accordion2 h3:hover {
    background-color: #e3e2e2;
}
.accordion2 h3.active {
    background-position: right 5px;
}
.accordion2 div {
    margin: 0;
    display: none;
}

HTML

<div class="accordion2">

    <h3>
        <div class="box"><img src='http://img.youtube.com/vi/tPgf_btTFlc'>
        </div>
    </h3>
    <div>text text text text text text text text</div>

    <h3>title</h3>
    <div>text text text text text text text text</div>

    <h3>title</h3>
    <div>text text text text text text text text</div>

</div>

Appreciate your help /M

Answer №1

delete the display: none; from your css

Your css sheet looks like this

body {
    margin: 10px auto;
    width: 570px;
    font: 75%/120% Arial, Helvetica, sans-serif;
}

.box {
  display:inline-block;
  padding: 3px;
  margin: 3px auto;
}

.accordion2 {
     min-height:95px;
     height:auto !important;
     height:95px;

}

.accordion2 h3 {
    padding-bottom: 1px;
    margin: 0;
    border-bottom: none;
    cursor: pointer;
    min-height:95px;
    height:auto !important;
    border:1px solid blue;
}
.accordion2 h3:hover {
    background-color: #e3e2e2;
}
.accordion2 h3.active {
    background-position: right 5px;
}
.accordion2 div {
/*    background: red;
*/    margin: 0;

}

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

I am experiencing difficulty in successfully transmitting a variable from my jQuery code to my PHP code

I've been attempting to pass a variable from my jQuery code to my HTML/PHP code using AJAX and POST. However, I'm encountering an error message stating "Notice: Undefined index: testData in C:\xampp\htdocs\teszt\test1.php on l ...

After calling the use method in Express, utilizing the get method

const express = require("express"); const bodyParser = require("body-parser"); const app = express(); app.use(bodyParser.urlencoded({ extended: false })); app.use((req, res, next) => { console.log("Executing first middlewar ...

Flamebeetle - Debugging code loaded programmatically

I have been using jQuery UI tabs to load pages that include JavaScript code. I am wondering if there is a way to debug this code using Firebug. I've checked the 'Scripts' tab in Firebug, but I can't seem to find them there under the cat ...

Add a horizontal line between two div elements to create a visual division in the middle

Here is a snippet of my HTML/CSS/JS code: <div id="blockcart-wrapper"> <div class="blockcart cart-preview"> <div class="header"> <a rel="nofollow" href="#"> <img class="cart-icon" src="https://via.placehold ...

What is the method for specifying input type in an HTML document?

I need assistance with controlling an input field labeled "Size" in HTML. The input should only allow users to enter Numbers and specific characters like X, ', and ". Other alphabets and characters should be restricted. I am working with AngularJS as ...

Discover a suitable option or craft one using Mongoose

I'm facing a challenge with handling page ids in my code. The scenario is as follows: Page.findById(pageId).then(page => { const pageId = page.id; .. }); If no page id is provided, I need to select the first available page that meets certain ...

Dividing image styles within css

I am trying to incorporate 4 arrow images into a CSS class (up, down, right, left). I started with a basic arrow css class: .arrow { background-repeat: no-repeat; background-position: center; } Next, I created subclasses like: .arrow .up { ...

The output of server.address() method in Node.js is ::

My memory serves me right, a few days back it was showing "localhost". I'm puzzled as to what altered server.address().address to now return double colons (::). According to my research, it seems to be returning an IPv6 address (::) because it's ...

After reaching the character limit, errors occur due to data being sent through Ajax requests on keyup

My website has a feature where users can input zip codes and get information based on that. However, I am facing an issue with the ajax call when users continue typing beyond the required number of characters for zip code entry. Even though the additional ...

Enhancing React Performance: Storing Component Identity in Redux State

Can I safely pass this to a Redux action creator from a component defined using React.createClass? In my code, I have created the following reducer: const unsavedChangesProtectionReducer = handleActions({ [ENABLE_UNSAVED_CHANGES_PROTECTION]: (unsaved ...

Attempting to increase the size of the menu text upon hover action

It seems like a basic mistake on my part, but I just can't seem to make it work. What I'm trying to achieve is that when you hover over a specific item in the menu, the text within that item should increase in size. However, currently it only en ...

Modal containing Jquery GalleryView

I am facing an issue with loading galleryView inside a modal. Even though using galleryView on its own works fine, I have been unable to make it work within a modal. Despite looking for solutions in previous posts, I couldn't find anything that fixed ...

Using AngularJS to refresh information stored in an array

My objective is to create a basic application that allows users to adjust their availability on weekdays. The code is functioning correctly as it retrieves data from the select box. However, I encounter an issue when trying to update Monday's data and ...

Switching the cursor to an image when hovering over an element is causing inconsistency in hover events triggering

Currently, I am attempting to implement an effect that changes the cursor to an image when hovering over a text element and reverts back to the normal cursor upon leaving the text element. However, this functionality is not working as expected when using R ...

The function of hasClass within an if statement appears to be malfunctioning

I'm struggling to figure out why my .hasClass function is not functioning correctly. I've implemented the Quick Search jQuery plugin, and below is the code I am using: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.mi ...

Querying a subarray in MongoDB

Here is a document I have: { "_id" : "someId", "name" : "myTeam", "team" : [ { "entity" : "size", "value" : 14 }, { "entity" : "returns", ...

Parameters for MongoDB search queries

I am currently working with a MongoDB query on a specific collection. Here is the structure of the query: common.db.collection('vb.vbStats').find({uid:uid, "vbs.vbNID":vbNID}, {"vbs.$":1}).toArray(function(err, result) {....} The collection I a ...

"What is the best way to manipulate arrays in vue.js using the map function

I'm currently dealing with a Vue code that incorporates anime.js. My code has grown substantially to over 1500 lines. In order for Stack Overflow to accept my question, I have only included 5 items of my sampleText, even though it actually consists of ...

Is it possible to modify the content of an element with a click event in Angular/HTML?

How can I implement a feature in my mat-accordion using mat-expansion-panels where the text becomes underlined when the panels are clicked? I want the title to be underlined when the panels are open and for the underline to disappear when they are closed ...

Setting maximum and minimum zoom limits for an element ID using JavaScript or jQuery

My application features a DIV element with the unique identifier of mainDiv. The issue I am facing is related to zooming functionality, as it currently lacks any set limits - both for scaling up and scaling down. I have been searching on Google for a sol ...