What is the best way to link buttons to specific drop down sections?

How can I create multiple drop down divs with different content for each button click?

JSFiddle: http://jsfiddle.net/maddiwu/xe6xtfqh/

.slide {
    overflow-y: hidden;
    max-width: 100%;
    overflow-x: hidden;
    max-height: 100vw;
    /* approximate max height */
    width:100%;
    /*height: 45vw;*/
    background:#2e2e2e;
    transition-property: all;
    transition-duration: 1s;
    transition-timing-function: cubic-bezier(1, 1, 1, 1);
}
.slide.closed {
    max-height: 0;
}
.banner7 {
    width:80%;
    background:#d8d8d8;
    margin-top:1.5vw;
    padding-top:2vw;
}
.banner8 {
    width:80%;
    background:#2e2e2e;
    margin-top:1vw;
    margin-left:10%;
    padding-top:2vw;
}

Answer №1

Unfortunately, I cannot provide code assistance due to time constraints, but I can offer a suggestion.
Consider implementing the MVC (Model View Controller) pattern to streamline rendering data within a single div.

Answer №2

One drawback of CSS is its inability to change a style based on the state of another element, such as click, hover, or scroll. Each div will have to listen for a click event and then trigger a method to animate the corresponding div, requiring the use of JavaScript.

For more information on JavaScript basics, you can visit: https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.click https://developer.mozilla.org/en-US/docs/Web/API/document.getElementById

Alternatively, using jQuery may provide a faster solution: http://api.jquery.com/click/

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

Issues arise when attempting to create smooth animations with 100% transform translate across different web browsers

After uncovering an ancient piece of JS code that I had once shared for free use, I discovered that a CSS animation bug from 3 years ago is still causing trouble today. The issue involves animating an element from left:100%/transform: translateX(100%) or ...

Extract the names and corresponding keys from an array, then display them as a list

I am currently working on extracting key names and sub key names from a file in order to display the results in a list format as shown below. Anna was removed by AdminWhoRemoved due to Removal Reason Ethan was removed by AdminWhoRemoved due to Removal Re ...

Displaying gratitude message using AJAX and executing PHP script

I've created a form where I want the "thank you" message to be displayed after submission and also run a PHP script to insert data into the database. However, currently, although the values are being passed correctly via the URL, the upis.php script i ...

Convert HTML templates into JavaScript on the client side using Angular framework along with Browserify, Babel, ES2015, and Gulp

Having trouble with my Browserify Angular configuration file, specifically when using require() to load HTML templates. I attempted to use stringify or browserify-ng-html2js in the transform() function, but it resulted in multiple transform calls in my gul ...

Encountering an Issue: The program is throwing a TypeError because it is unable to access properties of null when trying to read '

My goal is to upload an excel file using ng-click and the fileUpload($event) function defined in the app controller scope. I am utilizing xlsx to read the file in JSON format, but I encounter an error when running the code: <div> <input id ...

Attempting to utilize JSON.Stringify on Scripting.Dictionary objects will result in failure

In my current ASP classic project, I have integrated the JScript JSON class available at this link. This class can interact with both VBScript and JScript, closely resembling the code provided on json.org. However, due to team manager's requirement, I ...

Creating XML files using Node.js

What are some effective methods for generating XML files? Are there tools similar to the Builder in Rails, or any other recommended approaches? Appreciate any insights! ...

capturing the value of a button during the onChange event

I'm currently trying to retrieve the button value within an onChange event. My goal is to then bind this value to state, but unfortunately, I am receiving an empty value. <button onChange={this.handleCategoryName} onClick={this.goToNextPage}> ...

Invoking a JavaScript function using jQuery's AJAX

I'm currently working with jQuery and Ajax. Within my MainFile, I have the following code: <html> <head> <script src="Myscript.js"> </script> <script type="text/javascript"> $(doc ...

The content within the mat-card-content paragraph exceeds the boundaries of the mat-card container,

I recently began working with Angular Material and came across an issue. When I have a shorter text paragraph, it overflows the card. However, when I use a larger paragraph, the text wraps nicely. Here is the code snippet: <mat-card *ngFor="let s ...

What is the best way to troubleshoot a $http asynchronous request?

Is there a way to pause the program execution in AngularJS $http call after receiving a successful response? I've attempted to set a breakpoint at that point, but it does not halt the execution. I've also tried using the debugger directive, but ...

Need to return to the previous page following submission

Is there a way to redirect me to the premontessori page after I submit the form? Below is my function handleSubmit: handleSubmit(event) { event.preventDefault(); <Link to='/premontessori' style={{textDecoration:'none'}} & ...

Black and white emoji display on Windows 7 using Chrome and Edge browsers

To enhance the visual appeal of my website, I incorporate emojis using Emoji Unicode from https://www.w3schools.com/charsets/ref_emoji.asp. It has come to my notice that on Android, Mac, and iPhone devices, users see colored emoticons while those on Window ...

Troubleshooting Guide: Issues with Bootstrap 3 Modal Window Implementation

This question is so simple that it's embarrassing. I attempted to copy the code from http://getbootstrap.com/javascript/#modals directly into a basic page setup, but it's not functioning. It seems like I'm making a very silly mistake. Here i ...

What sets apart elem['textContent'] from elem.textContent?

When dealing with a HTMLElement in JavaScript, is there any distinction between the following lines of code: elem['textContent'] = "Test"; versus elem.textContent = "Test"; This question arises when setting the text content of an HTMLElement. ...

Discover the route followed by an object containing a specific key within an array of objects

Imagine having an array of dictionaries like the one below. How can I locate the object with id: 121 using JavaScript? I've been struggling to figure this out and would appreciate any hints or algorithms on how to achieve this. The desired result sho ...

Node.js request body is not returning any data

UPDATE: @LawrenceCherone was able to solve the issue, it's (req, res, next) not (err, res, req) I'm in the process of building a MERN app (Mongo, Express, React, Node). I have some routes that are functioning well and fetching data from MongoDB. ...

Can a VS Code theme extension be designed using JavaScript or TypeScript rather than JSON?

Currently working on a VS Code theme extension, I am interested in exploring the possibility of using JavaScript or TypeScript files instead of a JSON file. The idea of having all the theme information crammed into one massive JSON file feels disorganize ...

Dealing With HttpClient and Asynchronous Functionality in Angular

I've been pondering this issue all day. I have a button that should withdraw a student from a class, which is straightforward. However, it should also check the database for a waiting list for that class and enroll the next person if there is any. In ...

Sequencing asynchronous functions in Angular: Ensuring one function runs before another

When working with a save function that requires you to call another function to retrieve the revision number and make an API call, both of which are asynchronous in nature, how can you ensure one function waits for the other to execute? $scope.getRevision ...