Looking for a way to design versatile image sliders featuring multiple buttons for various sliders? I'm interested in crafting an image slider gallery tailored to different years

I am currently working on creating an image slider gallery displaying different years. However, I'm facing challenges in making it work properly. If I select a specific year like 2017, only the corresponding images should be displayed. Can someone assist me with this task? Despite following tutorials and videos, I haven't been able to complete it successfully yet. Your help is greatly appreciated as I continue to learn. Below are the sections of my HTML, CSS, and JavaScript code.

$(document).ready(function () {

  $('#myCarousel').carousel({ interval: 3000 });

  $('.multi-item-carousel .item').each(function () {
      var itemToClone = $(this);

      for (var i = 1; i < 6; i++) {
          itemToClone = itemToClone.next();

          if (!itemToClone.length) {
              itemToClone = $(this).siblings(':first');
          }

          itemToClone.children(':first-child').clone().addClass("cloneditem-" + (i)).appendTo($(this));
      }
  });
});

$(document).ready(function () {
    $('#show').click(function () {
        $('.menu').toggle("slide");
    });
});
$(document).ready(function () {
    $('#show1').click(function () {
        $('.menu1').toggle("slide");
    });
});
$(document).ready(function () {
    $('#show2').click(function () {
        $('.menu2').toggle("slide");
    });
});
#slider-text {
  padding-top: 40px;
  display: block;
  text-align: center;
}

#slider-text .col-md-6 {
  overflow: hidden;
}

#slider-text h2 {
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 400;
  font-size...

Answer №1

If you haven't already, you likely have the solution to this puzzle now. However, it may benefit someone else in need.

Based on your inquiry, it seems you desire a functionality akin to an accordion where selecting a year reveals that specific year while concealing all others.

If starting from scratch, I would opt for tabs with individual containers for each year to streamline the process. To adapt your current setup with minimal changes, consider adding a line to hide other items within each click function. For instance:


$(document).ready(function () {
    $('#show1').click(function () {
        $('.menu1').toggle("slide");
    $('.menu').hide("slide");
    $('.menu2').hide("slide");
    });
});

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

Guiding motion of a parental container using a button

This seems like a fairly straightforward task, but I'm getting a bit frustrated with it. Is there a way to move an entire div by simply holding down the mouse button on a particular button? let container = document.getElementById('abo ...

Avoid showing duplicate values in the optgroup selection

Show the database value in the optgroup option. If the value of the parsing controller is equal to the option's value, do not display it within the HTML tag. Value of the parsing controller: {{$getData->status}} This is how my view blade looks: ...

Looking for a clever CSS hack to remedy this problem

Hey everyone, I'm currently designing a website with a vibrant orange background and incorporating white social icons from the Font Awesome library. Check out the progress of my project below: CSS @import url('http://netdna.bootstrapcdn.com/bo ...

PHP Query Composer/Reporter

As I work on fine-tuning a web application, the support and explanations from members of this community have been incredibly valuable. I appreciate the assistance in simplifying complex concepts. One feature I wanted to include in my app was the capabilit ...

How come the rotation of my Three.js mesh gets thrown off when I adjust the scale?

I managed to achieve my goal of rotating a sphere around the x and y axes using the following code: // Update ball rotation. var tempMat = new THREE.Matrix4(); tempMat.makeRotationAxis(new THREE.Vector3(0,1,0), stepX/ballRadius); tempMat.multiplySelf(ball ...

Creating a unique HTML id using an evaluated expression

My goal was to create a minimalist version of the classic game "tic tac toe" using AngularJS. To achieve this, I had to come up with a unique solution by assigning each button a distinct ID (f+i). HTML <table> <tr ng-repeat="f in [5,10,15]"& ...

When attempting to fetch data from Strapi v4 and display it in ReactJS, all that is shown is an empty array

I've encountered an issue while trying to map data from Strapi, as I'm getting an empty array. Surprisingly, the endpoint functions properly when tested on Postman: https://i.sstatic.net/4B4O7.png The custom useFetch function seems to be malfunc ...

Issue with flickering scroll-snap in React component with useState

I've encountered an unusual flickering glitch that only occurs when using the combination of: css scroll-snap useState Sub-Components But it's strange because the issue only arises when these three are combined! https://i.sstatic.net/TvwyW.gif ...

What is the correct method for closing a style element in Nextjs JSX?

Having trouble adding some unique styling to a jsx component. The code snippet below is throwing an error when compiled. import Card from "./card"; export default function CardRow(){ return( <> <div> <Card> ...

The performance of the image slider is not smooth

After creating a basic javascript/css image slider as a learning exercise, I am now looking to implement it in real-world projects. However, the animation is choppy on my high-spec desktop and even worse on mobile devices. You can view the slider in action ...

Keep Array up-to-date as new elements appear on the webpage

Currently, I am developing a Chrome extension that requires me to retrieve the total number of books available in a library. The current code snippet is functioning correctly, but the issue arises when the page loads only half of the books initially and ...

Creating a CSS grid layout comprising of 40x40 boxes: A step-by-step guide

I'm trying to create a 40 x 40 grid of boxes with outlines that can be fully displayed on the screen without requiring scrolling. However, my current method causes the grid to exceed the screen size and forces me to scroll. If the screen size changes ...

Browser reports that the value "content" for flex-basis is not valid

Provided: .layout { display: flex; flex-wrap: nowrap; align-items: stretch; } .layout aside, .layout main { min-width: 100px; } .layout aside { flex: 0 0 content; background-color: red; } .layout main { flex: 1 1 content; background-c ...

Blank canvas for exploring SQL and PHP queries

I am currently working on a website that displays personal statistics for users. To achieve this, I am utilizing PHP to retrieve data from an SQL database. Below are the two files I am using: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E ...

Securing PayPal's purchase forms for safe online transactions

Trying to assist someone with a donation issue, but discovered that the source code allows for editing of values in the Paypal button. When selecting 5 points worth $5, it's possible to manipulate the values in the source code of the Paypal form. How ...

Encountered an error loading resource: server returned a 400 (Bad Request) status when using Angular with NodeJS

My Angular and NodeJS application with Express (v4.17.1) exposes a REST API like this: app.get('/myRestApi', function (req, res) { console.log('here you are ... '); res.end('success!\n'); }); The body of this API ...

Why is Selectpicker failing to display JSON data with vue js?

After running $('.selectpicker').selectpicker('refresh'); in the console, I noticed that it is loading. Where exactly should I insert this code? This is my HTML code: <form action="" class="form-inline" onsubmit="return false;" me ...

What is the best way to ensure webpacker compiled javascript only runs once the page has finished loading in a rails application

What is the best location to place window.onload for it to execute on every page within a Rails 6 application? ...

What is the process for assigning a random string value to each document within a mongodb collection using the mongo shell?

Looking to assign a randomly generated string property to every item in a MongoDB collection. Planning to leverage the mongo shell and the updateMany function for a swift and efficient solution. ...

Issue with javascript code not functioning post axios request

When working on my project, I utilize axios for handling Ajax requests. I crafted a script that attaches a listener to all links and then leverages Axios to make the Ajax request. Following the Ajax request, I aim to execute some post-processing steps. Aft ...