Display a div by clicking on another div using Jquery FlexSlider

Recently, I came across this code snippet:

$(document).ready(function(){
    $('.porslider > .slides > li > div > ul > li').click(function() {
        var which = $(this).index();
        $('#big').find('div').hide().eq(which).show();
    });
});

It works perfectly when clicking on an li item to display a corresponding div. However, the issue arises when trying to implement this in a flexslider. Here is a snippet of my HTML structure:

<div class="flexslider porslider">
    <ul class="slides">
        <li>
            <div>
                <ul class="porimages ulpor">
                    <li><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li class="mr"><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li class="mr"><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                </ul>
            </div>                
        </li>
        <li>
            <div>
                <ul class="porimages ulpor">
                    <li><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li class="mr"><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li class="mr"><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                    <li><a><img src="por_small/piWD00001.png" alt="" height="142" width="142"/></a></li>
                </ul>
            </div>                
        </li>
    </ul>
</div>

<div id="big">
    <div><img src="por_big/piWD00001.png" /></div>
    <div><img style="opacity: 0.5;" src="por_big/piWD00001.png" /></div>
    <div><img style="border: 2px solid red;" src="por_big/piWD00001.png" /></div>
    <div><img src="por_big/piWD00001.png" /></div>
    <div><img src="por_big/piWD00001.png" /></div>
    <div><img src="por_big/piWD00001.png" /></div>
    <div><img style="opacity: 0.1;" src="por_big/piWD00001.png" /></div>
    <div><img style="border: 2px solid blue;" src="por_big/piWD00001.png" /></div>
    <div><img src="por_big/piWD00001.png" /></div>
    <div><img src="por_big/piWD00001.png" /></div>
</div>

This CSS rule is applied:

#big div {
display: none;
}

I am looking for suggestions or solutions on how to modify the script to work with multiple slides. Currently, only the first five thumbnails are visible but I would like to display more. Any ideas on how to achieve this?

Thank you!

Answer №1

http://jsfiddle.net/4KhUb/4/

If you're encountering issues with your selectors in Flexslider, try this solution first. It seems that Flexslider adds additional elements to your HTML, which might be causing the problem.

$('.porimages > li').click(function() {
    var which = $(this).index();
    $('#big').find('div').hide().eq(which).show();
});

Alternatively, you can also use:

$('.porslider li li').click(function() {
    var which = $(this).index();
    $('#big').find('div').hide().eq(which).show();
});

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

Adjust the size of a div using absolute positioning

Can a div with absolute position be resized? I need this pink modal to maintain the same width as the input and resize accordingly. This modal will be utilized in a dropdown component, so it should resize along with the input. Moreover, is using absolute ...

Comparing `$('p:first');` with `document.querySelector('p');`

I am confused. $("p:first") chooses the initial p element. It is similar to document.querySelector("p"); Why do we need to use both methods? Apologies if this question seems silly, but I want to fully understand. UPDATE In what scen ...

Once the if condition is implemented, the functionality of the toggle button ceases to operate

Take a look at this demo link: http://jsbin.com/labuxuziraya/1/edit I encountered an issue where the button stops working after adding an if condition. I suspect there are some minor bugs in the code, but my level of experience is not enough to pinpoint t ...

Ajax RSS Feed - Weather Data from OpenWeatherMap

I am encountering an issue where the feed does not refresh with new news as they come in, even after selecting an option. This same problem is also occurring with openweather. I suspect that everything is being cached when it shouldn't be. Should I ch ...

Allow only a specific section to be scrollable, instead of the whole page

Currently, I am immersed in a project where one section must dynamically populate elements pulled from a database. Due to this dynamic nature, the quantity of elements can vary significantly. The challenge lies in our design concept, which aims to elimina ...

Plugin using jQuery that adds a UserVoice-inspired feedback tab to any webpage

Does anyone know of a jQuery plug-in that can replicate the fixed position tabs often seen on websites, where the tab is affixed to either the left or right side of the webpage? If you're looking for an example, UserVoice offers a script to add a fee ...

Leverage JavaScript variables within PHP

Seeking assistance on using javascript variable in php. After researching various resources such as stackoverflow and google, I have yet to find a suitable solution. Although aware of the distinction between client-side scripting in js and server-side proc ...

Is it possible to forcibly align the entire page to the center or eliminate the right margin?

We appreciate you taking the time to read this post in advance. Below is a link to the reproduction: Purpose: The goal here is to center the div.home-text (blue area) and eliminate the margin-right to prevent visitors from inadvertently scrolling to empt ...

Height of CSS border-top

I'm facing an issue with setting the height of my top border. It seems like a traditional solution is not possible based on what I have read so far. However, I am determined to find a workaround for this problem. My goal is to have the border align at ...

Errors are being encountered with React.js Bootstrap, specifically when attempting to complete basic tasks

Today is my first time using bootstrap with React and I am facing an issue that I cannot seem to figure out. I am attempting to change the placeholder text on an input field when it is in focus, but I keep getting an error message. let ColorInput=docume ...

Is the jQuery ajax .done() function being triggered prematurely?

Struggling with a problem here. I'm dealing with this code (simplified): var initializeZasilkovna = function () { // Initialize object window.packetery.initialize(); }; // Check if the object doesn't exist if (!window.packetery) { // It ...

Tracking the progress of an AJAX call with a progress bar or progress status

Using an ajax call, I want to display progress status inside a text box. Below is the code for the ajax call: <input type="text" name="cm" id="cm" /> <script type="text/javascript" language="javascript"> $('#cm').blur(function() ...

Running two blocks of scripts (utilizing lab.js as a loading manager)

I am currently facing an issue where I am trying to load two separate blocks of `lab.js` in different locations. However, when I attempt to utilize functions from the second block that are called from files loaded in the first block, they are showing as un ...

The functionality of my bootstrap carousel seems to be malfunctioning as the fdi-Carousel slide is

Whenever I check for errors in the Chrome console, I come across this error: Uncaught ReferenceError: $ is not defined. It seems to be related to my code. Can anyone help me identify what might be causing this issue? Below is a snippet of my code from &apo ...

Clicking on the title link will open the content in an iframe, but the image

Having trouble with a previous post but I've created a codepen to illustrate the issue. Hoping someone can help me out! Check out the codepen here: "https://codepen.io/Lossmann/pen/GRrXyQY" ...

Transform your HTML table into clickable links

https://i.sstatic.net/forOz.jpg Just starting out in html. Here's my html code that retrieves Json data from the server and displays it in an HTML table format. Could someone modify my html code to include a button between Video Link and Video Im ...

Tips for creating a unique parent tag and child tag with onclick functionality on a b-form-checkbox without repeating code

As I work on a li tag with various child elements, including a b-form-checkbox, I encountered an issue. I want the checkbox to function properly when clicked anywhere inside the li tag, including on the checkbox itself. However, when I click directly on th ...

Instead of using divs, try incorporating your personalized tags

Currently, I am working on developing a web app. I have been considering whether it would be beneficial to use custom HTML tags instead of divs. By utilizing our own tags in place of classes, the process of binding dynamic content could potentially become ...

Issue with knockout data-binding not functioning properly on Android device running version 4.2

Having trouble with data binding in my HTML control using Knockout JS: I'm working with an input checkbox like this: <input type="checkbox" id="chbText" data-mini="true" data-bind="checked: chkAddLabel" /> I've bound the chkAddLabel pro ...

Using `ng-init` to initialize data in AngularJS

I am currently attempting to determine whether the new item being created is a service or a product. My goal is for 'product' to be automatically selected by default. <div ng-init="pr.type=Product"> <div class="form-group"> < ...