In Bootstrap 3, you can toggle individual collapsible items without affecting others by only closing the specific

I am facing an issue with my Bootstrap collapsible elements. I came across an answer that includes the necessary javascript to close only the collapsible items in my table, while leaving other collapsible items on the page (in the menu) unaffected. These items are designed to be manually opened and not automatically closed. However, after implementing the javascript code from the provided answer, opening one collapsible item results in all other collapsibles on the site being closed. How can I make it so that only specific collapsibles are closed?

My desired outcome can be better explained through this JSFiddle exampleclick the link to view the code. In this example, clicking on a row in the first table should open the content, and clicking on another row in the SAME table should close the previously opened one. Clicking on a row in the second table should not affect the opened content in the first table.

Thank you to everyone for your assistance! :D

Answer №1

<script>
    $(document).ready(function(){

    $(".collapse").on('hide.bs.collapse', function(){
        alert('Get ready to hide the collapsible content.');
    });
    $(".collapse").on('hidden.bs.collapse', function(){
        alert('The collapsible content has been successfully hidden.');
    });
});
</script>

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

Modifying element values with jQuery by selecting identical elements

In one of my pages, I have encountered an issue where the same web part is displayed multiple times. The problem arises with the z-index when the dropdown in the web part control opens up. The web part placed further down the page ends up hiding the dropdo ...

Obtain asynchronous view model for component

Is it possible to retrieve a view model from the server and incorporate it into my component? I attempted to do so with the following code snippet, but it is not working as expected: function fetchViewModelFromServerAsync(){ setTimeout(function(){ ...

What causes the Element to be null in Vue.js?

Could someone please clarify why the console.log output is showing as null, and provide guidance on how to resolve this issue? <template v-for="day in getMonthLength()"> <td> <input :id="day" type=number :value=&qu ...

The disadvantages of manipulating DOM in controllers in AngularJS

Many experts advise against performing DOM manipulations in AngularJS Controllers, but it can be challenging to fully understand why this is considered a best practice. While sources mention issues with testing and the primary purpose of controllers for di ...

What is the best way to link this to a function in AngularIO's Observable::subscribe method?

Many examples use the Observable.subscribe() function in AngularIO. However, I have only seen anonymous functions being used like this: bar().subscribe(data => this.data = data, ...); When I try to use a function from the same class like this: update ...

What steps do I need to take in order to load the static folder from a CSS file?

Is there a way to load the static folder from a CSS file? I attempted to import using URL(), however, it was unsuccessful. I am looking to utilize the static path in order to apply a background to an element. .input_card:checked+.check-box { backgroun ...

Updating serialized $_POST array with new key/value pair using jQuery AJAX

Is there a way to insert additional values into a serialized $_POST array before sending an AJAX request using jQuery? Here's the situation: $('#ajax-preview').on('click', function(e) { e.preventDefault(); var formData = ...

Incorporate an external object not native to the Angular framework within a factory

We're in the midst of a debate and I'm hoping you can help us reach an agreement. Imagine I have a basic factory set up like this: angular.module('myModule', []) .factory('Fact', function() { var Fact = function() { ...

Unlocking the Interactive Potential of CSS Across All Screen Formats

I am currently working on transforming my website into an engaging and interactive platform. My first challenge: The alignment of the logo image does not meet my desired specifications. Whenever the screen width exceeds 1200 pixels, there seems to be exc ...

Enhance your website design with Bootstrap's unique styling for jumbotron elements

I am currently working on developing a mobile website for calendar events and I need some help. Here is the basic version of the site that I have created so far: The issue I am facing is that the purple backgrounded areas only cover the text, rather than ...

What could be the reason for scrapy not returning any URLs?

Recently, I attempted to develop a tool to simplify my apartment search and access relevant information quickly (the website is not very user-friendly). However, I have encountered an issue and I may be overlooking something obvious...or perhaps I'm j ...

How to style the first column of the first row in a table using CSS without affecting nested tables

Having some challenges with CSS selectors, I'm hoping to find some assistance here. Presented with HTML code that resembles the following: <table class=myTable> <tr> <td>this is the td of interest</td> </tr> ...

React form submissions result in FormData returning blank data

I am having trouble retrieving the key-value pair object of form data when the form is submitted, using the new FormData() constructor. Unfortunately, it always returns empty data. Despite trying event.persist() to prevent react event pooling, I have not ...

Selecting specific categories to display on the homepage and limiting the number of images shown

<<html> <head> <meta charset='utf-8'> <meta http-equiv='X-UA-Compatible' content='IE=edge'> <title>Gallery</title> <!-- CSS only --> <link href="https://cdn.jsdel ...

The object FormData cannot be instantiated as a constructor

I'm currently facing an issue while trying to create an AJAX request to upload an image. The problem arises when I attempt to initialize the FormData object. The error message in my console states: "dataForm is not a constructor". Any ideas on how I ...

Storing the options' ids in an array within a select box using JavaScript: tips and tricks

Check out this snippet of HTML code: <select id="s1"> <option value="volvo" id="o1">Volvo</option> <option value="saab" id="o2">Saab</option> <option value="opel" id="o3">Opel</option> <option value="au ...

Unable to convert date data for display on D3 line graph

I am attempting to replicate a line graph similar to the one in the following fiddle link: http://jsfiddle.net/wRDXt/2/ In the example, the date is used as new Date(2013, 17, 1). The JSON data I have is structured as shown below, [{ "_id": "bb68d8a2 ...

The video rendered with fluent-ffmpeg appears to have an elongated image

I am working on combining an mp3 audio file with a jpg image file to create a new mp4 video. Although I have a functional fluent-ffmpeg command that accomplishes this task, there is an issue where the image gets stretched in the final output video, especia ...

Need to create a callback within a sequence of events?

Is it possible to create a callback chain like this? Widget.update(...).onUpdate(function(data){ console.log('updated'); }); Here is the current code snippet: var Gateway = {}; Gateway.put = function(url, data, callback) { $.ajax({ ...

Header alignment issue in JQGrid

Utilizing 4.4.4 - jQuery Grid and <= jquery 1.8.2, this is how I set up my jqgrid: function FAGrid() { var url1 = 'URL'; $("#FAList").jqGrid({ url: url1, datatype: 'json', mtype: 'POST', ...