Switch up the current Slick Carousel display by utilizing a div element

We have implemented the slick carousel to show only one slide at a time within the

<div class='item__wrapper'>
. Beneath this are three items, and we want the slick carousel to update when any of these items are clicked.

Issues

  1. Using item__boxes as a slick carousel causes styling conflicts, preventing us from using $('.item__boxes).slick({});
  2. Clicking on any item in item__boxes always sets the item__wrapper to slide 3

Query

  • How can we configure the item__boxes so that clicking on an item aligns with our intended outcomes? For example, clicking on the second item should set the item__wrapper to the second slide.

Goal/Expected Results:

  1. Clicking on the first item should make the first slide active in item__wrapper
  2. Clicking on the second item should activate the second slide in item__wrapper
  3. Clicking on the third item should display the third slide as active in item__wrapper
  4. Achieve goals 1-3 without utilizing $('.item__boxes).slick({});

Code:

$('.item__wrapper').slick({

          infinite: true,
          speed: 1500,
          dots: false,
          prevArrow: false,
          nextArrow: false
});

$('.item__boxes').on('click', function() {

var slickIndex = $(this).attr('data-slick-index');
$('.item__wrapper').slick('slickGoTo', slickIndex);
});
.filter {
  width: 100%;
  height: 100%;
  padding: 45px;
  margin-right: -45px;
}
.item {
  display: none;
  position: relative;
}
.item.active {
  display: block;
}
.item1 {
  background-image: url("https://placeimg.com/1000/480/nature");
}
.item2 {
  background-image: url("https://placeimg.com/640/480/arch");
}
.item3 {
  background-image: url("https://placeimg.com/640/480/tech");
}
.item__wrapper {
  max-width: 60%;
  position: relative;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: rgba(238, 238, 238, 0.5);
}
.item__img img {
  top: 0px;
  position: absolute;
  width: 100% !important;
  opacity: 0.5;
}
.item__text {
  top: 0px;
  position: relative;
  min-height: 100%;
  line-height: 1.4;
  padding-right: 70px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: top;
  justify-content: center;
}
.item__boxes {
  display: flex;
  position: relative;
  opacity: 0.9;
}
.item__boxes > div {
  border: 1px solid;
}
.col-padding {
  padding: 16px 16px 5px 16px;
}
.col-m-12 {
  width: 100%;
}
@media (min-width: 1024px) {
  .col-t-6 {
    width: 50%;
  }
}
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css"/>

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.css"/>
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>

<div class="item__wrapper">
   <div class="item active" id='item1'>
<div class="item__text">
<div class="filter">
<h3>Some title 1</h3>
<p>Efficiently communicate sticky quality vectors after compelling growth strategies. Compellingly scale future-proof content rather than enterprise users. Uniquely build scalable applications vis-a-vis performance based functionalities. Monotonectally procrastinate.</p>
</div>
</div>
    </div>
  <div class="item active" id="item2" >
        <div class="item__text">
<div class="filter">
<h3>Some title 2</h3>
<p>Efficiently communicate sticky quality vectors after compelling growth strategies. Compellingly scale future-proof content rather than enterprise users. Uniquely build scalable applications vis-a-vis performance based functionalities. Monotonectally procrastinate.</p>
</div>
</div>
    </div>
  <div class="item active"  id="item3" >
        <div class="item__text">
<div class="filter">
<h3>Some title 3</h3>
<p>Efficiently communicate sticky quality vectors after compelling growth strategies. Compellingly scale future-proof content rather than enterprise users. Uniquely build scalable applications vis-a-vis performance based functionalities. Monotonectally procrastinate.</p>
</div>
</div>
    </div>

   
</div>
<div class="item__boxes">
     <div class="box col-m-12 col-t-6 col-padding" data-slick-index="-1">
<div>Some Title</div>
<div>Enthusiastically incubate diverse initiatives without multifunctional strategic theme areas.</div>
</div>
<div class="box col-m-12 col-t-6 col-padding" data-slick-index="0">
<div>Globally Title</div>
<div>Globally impact integrated infomediaries via seamless mindshare. </div>
</div>
<div class="box col-m-12 col-t-6 col-padding" data-slick-index="1">
<div>Distinctively Title</div>
<div>Distinctively strategize long-term high-impact ideas whereas client-centered leadership skills.</div>
</div>
</div>

Answer №1

Give this a shot.

$('.item__wrapper').slick({
  infinite: true,
  speed: 1500,
  dots: false,
  prevArrow: false,
  nextArrow: false
});

$('[data-slide]').click(function(e){
  var slideno = $(this).data('slide');
  $('.item__wrapper').slick('slickGoTo', slideno);
});
.filter {
  width: 100%;
  height: 100%;
  padding: 45px;
  margin-right: -45px;
}
.item {
  display: none;
  position: relative;
}
.item.active {
  display: block;
}
.item1 {
  background-image: url("https://placeimg.com/1000/480/nature");
}
.item2 {
  background-image: url("https://placeimg.com/640/480/arch");
}
.item3 {
  background-image: url("https://placeimg.com/640/480/tech");
}
.item__wrapper {
  max-width: 60%;
  position: relative;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: rgba(238, 238, 238, 0.5);
}
.item__img img {
  top: 0px;
  position: absolute;
  width: 100% !important;
  opacity: 0.5;
}
.item__text {
  top: 0px;
  position: relative;
  min-height: 100%;
  line-height: 1.4;
  padding-right: 70px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: top;
  justify-content: center;
}
.item__boxes {
  display: flex;
  position: relative;
  opacity: 0.9;
}
.item__boxes > div {
  border: 1px solid;
}
.col-padding {
  padding: 16px 16px 5px 16px;
}
.col-m-12 {
  width: 100%;
}
@media (min-width: 1024px) {
  .col-t-6 {
    width: 50%;
  }
}
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css"/>

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.css"/>
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>

<div class="item__wrapper">
   <div class="item active" id='item1'>
<div class="item__text">
<div class="filter">
<h3>Title One</h3>
<p>Description for title one.</p>
</div>
</div>
    </div>
  <div class="item" id="item2" >
        <div class="item__text">
<div class="filter">
<h3>Title Two</h3>
<p>Description for title two.</p>
</div>
</div>
    </div>
  <div class="item"  id="item3" >
        <div class="item__text">
<div class="filter">
<h3>Title Three</h3>
<p>Description for title three.</p>
</div>
</div>
    </div>

   
</div>
<div class="item__boxes">
     <div class="box col-m-12 col-t-6 col-padding" data-slide="0">
<div>Some Title</div>
<div>Description.</div>
</div>
<div class="box col-m-12 col-t-6 col-padding" data-slide="1">
<div>Globally Title</div>
<div>More Description</div>
</div>
<div class="box col-m-12 col-t-6 col-padding" data-slide="2">
<div>Distinctively Title</div>
<div>Another Description.</div>
</div>
</div>

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

Dynamic images blending seamlessly with a fluid background aesthetic

Hello everyone, I could really use some assistance! My client is looking for a WordPress page with full screen backgrounds. Specifically, on one of the pages, they want 3 images placed on a fullscreen background image that remain in a fixed position while ...

Tips for successfully integrating jQuery UI datepicker in a form loaded through an ajax request

Having a calendar page with links that load forms using ajax into bootstrap popovers for each day. The loaded form includes start and end date fields, to which jQuery binds datepicker as follows: $( ".datepicker" ).datepicker({ changeMonth: true, chan ...

Migrating a few PHP scripts to ColdFusion

Hey there, I'm currently in the process of converting some really basic PHP code to be compatible with a development server that only supports CF. This is completely new territory for me, so I'm looking for some guidance on how to port a few thin ...

Leverage data retrieved from a JSON response to dynamically populate variables on a webpage through an AJAX API

After making an AJAX call to my API and receiving JSON data, I am looking to dynamically update my webpage using specific values from the JSON response. <div class="Name"></div> <div class="Role"></div> <div class="Location"> ...

jquery animation does not reset after event occurs

My script is functioning well to animate my elements, but I am facing an issue where when the function is called again after a timer, the elements move to their correct positions but do not initiate a new animation. The goal of the function updateFlights( ...

Triggering a JQuery Toggle Button

This is the code I'm currently working with: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, fu ...

What is the best way to ensure my php variable is easily accessed?

Recently, I've been working on implementing a timer and came across the idea in a post on Stack Overflow. <?php if(($_SERVER['REQUEST_METHOD'] === 'POST') && !empty($_POST['username'])) { //secondsDif ...

Error message appears when attempting to display a variable in HTML without defining it

Python if($count == 1) { session_register("username"); $_SESSION['username'] = $username; header("location: ../home"); }else { $error = "Your Login Name or Password is invalid"; } CSS -- line 43 <?php echo "<p cl ...

Discover the worth within the outcome obtained from the AJAX request

I have an action that returns a tuple containing a boolean value and a string. How can I retrieve the first boolean value from the result, which could be either true or false? This is the action: public Tuple<bool, string> Check This is the AJAX c ...

Arranging nested divs in relation to one another in a specific position

This code represents a chart in HTML. The goal is to have the second (middle) div start where the first (top) div ends, which has a width of 75px. To achieve this, the margin-left for the middle div is set to 75px in the following styles. Following the sam ...

Vue.js template is failing to properly render hyperlinks, although basic string output is functioning as expected

Whenever I print attrib.link, everything works perfectly fine, <div v-for="attrib in attributes"> {{ attrib.link }} </div> However, when I try: <div v-for="attrib in attributes"> <a target='_blank' href={{ attrib.link } ...

Discovering the maximum value in AngularJS using an expression (complete with a bug demonstration)

How can I set a maximum value for an input that can be either a numeric amount or a percentage? Is it possible to use ng-max to set the max value to 100 if the input is a percentage, and leave it blank if it's a numeric amount? I attempted the follo ...

A guide on converting character objects to strings

Presented below is an array of characters: Resource {0: "-", 1: "-", 2: "-", 3: "-", 4: "-", 5: "B", 6: "E", 7: "G", 8: "I", 9: "N", 10: " ", 11: "C", 12: "E", 13: "R", 14: "T", 15: "I", .... } I am looking to convert it into the following format: --- ...

Strategies for tracking distinct property values in Firestore

Is it possible to count the occurrences of unique values in Firestore? For instance, if there are 1000 documents with dates and only 50 different dates repeated, how can I get a list of each date along with its frequency? Context: These documents represe ...

Having difficulty launching a new window within an app built with Electron and Nexjs (Nextron)

Attempting to launch a (Nextjs-generated) page in a new window is causing an error message to appear: Uncaught ReferenceError: global is not defined Here is the full error: react-refresh.js?ts=1665849319975:10 Uncaught ReferenceError: global is not de ...

Instructions for passing a single value from a while loop and showing a different value in a text box through PHP

Can one value be displayed while sending another value in an Input text field simultaneously? I have a form that displays details in descending order, but when I update the details from another page, they are being updated in ascending order instead. Cod ...

Internet Explorer causing problems with JQuery

I encountered an error with the following code snippet: jQuery.post('/user/result/generate',{ 'id': getHidden() }, function(html) { $('#result').html(html); }); The error message is: ...

Using Asp.net to make a jquery ajax request

I've been practicing jQuery AJAX calls and I've encountered an issue. Whenever I run my project, I receive an INTERNAL SERVER ERROR 500. Can someone explain what this error means and how I can resolve it? To give some context, I created a sample ...

Watch as jQuery preloads every select list

There are two select lists, and the second one is dependent on the first. After loading the second list, I want to trigger some alerts. What is the most effective approach to accomplish this using jQuery? Let's say the second list is populated in the ...

Is there a way to align six columns on the left side and have a dynamic column on the right that fills the width of the browser window?

Is there a way to make a fluid container in Bootstrap 5 that contains a normal container on the left with 6 columns of content, while allowing the right side of the container to expand to the end of the browser window? When using a normal fluid container, ...