Pressing the button will reveal the contents of .container3

If you require any additional information, please feel free to reach out.

I find it quite puzzling why I am struggling to solve this.

While I can successfully navigate from .container1 to .container2 using the first exit button, I'm facing difficulties in moving from .container2 to .container3 with the second exit button.

To view the code example provided, scroll down to locate the exit button.

The issue lies in the fact that clicking on the second exit button should direct me to .container3.

The appearance of the second exit button follows after clicking on the first exit button.

Reproducible Code Snippet: https://jsfiddle.net/reuqancf/

Complete Code I'm working on: https://jsfiddle.net/pzn98Lw6/

Take a look at this demo code: https://jsfiddle.net/h5vkt3br/

You can observe its functionality there.

Analyze the demo code closely to understand how it's structured.

In the code I'm currently working on, clicking on the second exit button is expected to lead me to .container3, but this is not happening.

After clicking the exit button for the first time, it triggers the "initial-fade" animation.

...

Answer №1

To address the issues at hand, there are various approaches that can be taken. Let me outline the problems and provide one solution to achieve the desired outcome.

Upon reviewing your css code, it appears that the class .bg2 is intended to display the div with the class .container3.

Your current css:

    .bg2 .container3 {
      display: flex;
    }

To successfully hide the divs with classes .container1 and .container2 when the .bg2 class is applied, you need to update your css as follows:

    .bg2 .container1, .bg2 .container2 {
      display: none;
    }

JS Implementation:

The JavaScript function that adds the .bg1 class runs only once during initialization, which prevents the addition of the .bg2 class. To resolve this issue, consider moving the call to resetPage() from the animationEndHandler() function to the exitClickHandler() function. This way, it will be executed each time the exit button is clicked.

    function animationEndHandler(evt) {
      const animationName = evt.animationName;
      console.log(animationName);
      if (animationName === "initial-fade") {
        body.classList.remove("initial-fade");
        // move this to exitClickHandler()
        // resetPage();
      }
    }
 
    function exitClickHandler() {
      body.classList.add('initial-fade');
      resetPage();
    }

Another adjustment needs to be made in the resetBackground() function. Currently, it only adds the bg1 class to the body tag. By introducing a counter variable, we can ensure that the appropriate class (bg2) is added in sequence according to your styling requirements.

    let counter = 1;
    function resetBackground(backgroundSelector) {
      const background = document.querySelector(backgroundSelector);
      background.classList.add("bg" + counter);
      counter++;
    }

There are multiple strategies available for managing the visibility of video containers. I trust this guidance proves beneficial to you.

For a demonstration, you can access a functional jsfiddle via this link: https://jsfiddle.net/rpb138/xvr2uzse/3/

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

Creating a scheduled redirect button using JavaScript and another button to cancel it

I'm facing an issue with my code. When the first button is clicked, it redirects the user to a different URL after 10 seconds. However, I'm struggling to make the second button cancel the redirect if pressed before the 10 seconds are up. Despite ...

Synchronize numerous devices seamlessly using React Native without an internet connection

I'm facing an issue where multiple Android devices are connected to the same WiFi network but there is no internet connection. I need to sync data between these devices without requiring internet access. Is it possible to synchronize data on a local n ...

The hamburger menu for mobile devices is not functioning properly on the website's mobile version, however it operates correctly when the screen is resized

Currently, I am facing an issue with the hamburger menu not responding on my mobile device. Oddly enough, it does work when I resize my browser window to mimic a mobile size. There seems to be a glitch happening, but I'm struggling to pinpoint the exa ...

I'm experiencing difficulties with app.use() not functioning in my specific case, even though the paths are identical

My goal is to transfer the dist folder from the server to the client. When I use the following command, it works perfectly: app.use('/', express.static( Path.join(__dirname, '..', 'node_modules', 'del-js-webapp', &a ...

Unable to display results in the control: select2 version 4 ajax data is not showing up

Ever since transitioning to version 4 of the select2 plugin, I've encountered an issue with my ajax requests. Although I receive a response in the console showing as an array, the results are not appearing in the select2 control. The HTTP response l ...

The URL http://localhost:3001/users/signup returned a 404 error, indicating that the page was

Hello, I've been working on setting up my user routes using Sequelize for MySQL. However, when I try to test my requests by sending them to http://localhost:3001 via Postman, I'm receiving a 404 (Not Found) error for http://localhost:3001/users/s ...

Here are some tips for retrieving information from a JavaScript object

My goal is to extract the values of free_time, done_ratio, criticalTask, and dependency from a JavaScript object for each task. I attempted to achieve this, but unfortunately, it didn't yield the desired results. var mock_data_allocation = {"alloc ...

Adding JSON content to a form for editing functionality within an Angular 8 CRUD application

I am currently working on building a Single Page Application using Angular 8 for the frontend and Laravel for the backend. I have been able to successfully pass data to the backend via JWT, and everything is functioning as expected. The application follows ...

Validating the similarity of classes with JQuery

Currently, I am working on creating a quiz game using HTML, CSS, JQuery, and potentially JavaScript. I am looking to implement an if statement to check if a dropped element is placed in the correct div (city). My approach involves utilizing classes to comp ...

Is there a way to customize the hamburger icon for the navigation bar in Bootstrap 4?

Struggling to update the icon in the Navbar for bootstrap 4. Here's my current HTML: <nav class="navbar fixed-top navbar-expand-md navbar-custom"> <a class="navbar-brand" href="#"> <img src="images/logo.svg" width="60px" style="m ...

Determine the number of inputs within a div and increment each one by +1 using jQuery

I am currently working on developing a slider and have successfully completed most parts of it, except for the challenge of counting input fields using jQuery and assigning an incremented number to each of them upon action completion. On my slide, I have ...

Tips for customizing the appearance of a checkbox made with AngularJS

I need to style the checkbox using CSS without modifying the HTML code provided due to company restrictions. Is there a way to customize the appearance of the checkbox purely through CSS? Below is the AngularJS code snippet: <label class="form-lbl n ...

Guidance on assigning a value retrieved from an external API to an input field with the combined use of formik and MUI

Currently, I am facing an issue while trying to input a value obtained from an API into a TextField MUI component utilizing formik. The concept here is that the form acts as one component which is then utilized in another component. If a value is received ...

What is the best way to customize the MenuProps of Material UI Select component using createTheme?

I'm trying to update the dropdown menu style of my Material UI Select component using createTheme, but I'm having trouble getting it to work. https://i.sstatic.net/zpVjW.png Here is the code I have so far. Can you spot what might be causing the ...

Looping through an array using NgFor within an object

I've been working on pulling data from an API and displaying it on a webpage. Here is the JSON structure: {page: 1, results: Array(20), total_pages: 832, total_results: 16629} page: 1 results: Array(20) 0: adult: false backdrop_path: "/xDMIl84 ...

Reducing the size of the website does not necessarily mean the body will be at 100% width

While inspecting the site, I noticed that the body does not extend to 100% width of the screen when I reduce the size of the site. After removing the Bootstrap classes, the issue seems to be resolved. I even tried adding body{width: 100%} but it did not h ...

Image taking up the full width placed within a container with a set width dimension

https://i.sstatic.net/d1WWJ.png I am trying to make sure that the images expand to fill the entire width of the div they are placed in. Mainly using Bootstrap 4 for styling, but also incorporating some additional elements... <div class="row py-5"> ...

Angular default route with parameters

Is it possible to set a default route with parameters in Angular, such as www.test.com/landing-page?uid=123&mode=front&sid=de8d4 const routes: Routes = [ { path: '', redirectTo: 'landing-page', pathMatch: 'full' }, ...

Unable to display a Google map within a webview when viewing a local HTML file

I am currently working with a local HTML file called basicmap.html that includes the following code: <!DOCTYPE html> <html> <head> </head> <body> <div id="map"></div> <script> ...

Issues arise with Highcharts Sankey chart failing to display all data when the font size for the series is increased

I am currently working with a simple sankey chart in Highcharts. Everything is functioning correctly with the sample data I have implemented, except for one issue - when I increase the font size of the data labels, not all the data is displayed. The info ...