Tips for incorporating captions into a slideshow

I've been experimenting with different methods to include captions in my slideshow, but haven't had much success. I simply want to add a div at the bottom of each image. Do I need to modify my script or should I consider adding something else?

HTML:

<div class="minislider">
     <img src="http://www.no-margin-for-errors.com/wp-content/themes/NMFE/images/fullscreen/1.jpg" />
     <img src="http://www.no-margin-for-errors.com/wp-content/themes/NMFE/images/fullscreen/2.jpg" />
     <img src="http://www.no-margin-for-errors.com/wp-content/themes/NMFE/images/fullscreen/3.jpg" />
     <img src="http://www.no-margin-for-errors.com/wp-content/themes/NMFE/images/fullscreen/4.jpg" />
</div>

CSS:

.minislider {
    width: 321px;
    height: 242px;
    background-color: #649696;
    position: relative;
    float: left;
    left: 76px;
    top: 11px;
    border-radius: 10px 10px 10px 10px;
}

.minislider img {
    width: 311px;
    height: 232px;
    position: absolute;
    left: 5px;
    top: 5px;
}

JQUERY:

$(document).ready(function (){
    $('.minislider img:gt(0)').hide();
    setInterval(function(){
        $('.minislider :first-child').fadeOut()
            .next('img').fadeIn()
            .end().appendTo('.minislider');
        }, 3000);
});

http://jsfiddle.net/pedram68/tntpQ/

Answer №1

In agreement with Putvande's suggestion, it would be necessary to enclose your image and caption within a div element. The jQuery code can then be adjusted accordingly:

$(document).ready(function (){
    $('.minislider>div:gt(0)').hide(); //Using ".minislider>div" instead of ".minislider div" allows for nested div elements.
    setInterval(function(){
        $('.minislider>div:first-child').fadeOut()
            .next('div').fadeIn()
            .end().appendTo('.minislider');
        }, 3000);
});

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

Utilize the jQuery ajaxForm plugin to retrieve the form ID and implement an upload progress bar

On a single page, I have multiple forms that are submitted using ajaxForm and display upload progress. Each form has the same class '.input_form', a unique id, and a hidden input field with the name and class of 'category' containing a ...

Looking to retrieve the text content of an element using jQuery?

My goal is to use jQuery mobile to transfer a user to a linked page when they click on an <li> element, and then display an alert with the text of the list element they clicked. However, my current implementation only shows an empty alert box. < ...

Using Jquery to add new HTML content and assign an ID to a variable

Here is some javascript code that I am having trouble with: var newAmount = parseInt(amount) var price = data[0]['Product']['pris']; var id = data[0]['Product']['id']; var dat ...

What is the best way to achieve a stylish Bootstrap modal design with a blurred and transparent header, as well as a left sidebar that seamlessly blends into

Is it feasible to create a modal with a blurred (transparent) background for the header section, allowing the site to show through? Additionally, can a sidebar on the left side of the modal also be transparent and blurred, revealing the site underneath? C ...

Is it possible to retrieve the chosen options text from a select menu using jQuery with the feature of "Dynamic option values"?

I need assistance with displaying dynamic drop-down values where only the id values are presently available. What would be the best approach to achieve this? <div class="form-group"> <select class="wp-form-control" id="joblocation" name="jobl ...

Transitioning from jQuery post to AJAX is a unique process that requires slightly different coding techniques

Is there a way to convert a jQuery $.post call to an AJAX post call? I need to send an ARRAY to the controller. $.post(url, function (data) { $('#myModal .modal-title').html($link.text()); $('#myModal .te&apo ...

Clicking on numerous hyperlinks using Selenium IDE

Looking to automate some websites using Selenium IDE? Here's how you can achieve this: Click Click Link 1 do some clicking inside that link go back to the list of links Click Link 2 do some clicking inside that link go back to the list of links Cli ...

Run a script tag prior to displaying the modal

Currently, I am attempting to display a bootstrap modal with dynamic content. One of the values being passed to the modal is the HTML that should appear inside it. The issue I am facing is that within the HTML content being passed, there is a script tag t ...

Presenting data in various formats

I've got a JSON file with a list of data that includes months and years. I want to display all the months, but have the year only appear once in a big block area. Here's an image example: https://i.stack.imgur.com/Ps3OF.png The image demonstrates ...

Are there any disadvantages or more efficient options for using jQuery to call .NET Page Methods?

I am currently exploring a more efficient approach to handling ajax calls in our existing .net webforms app. I have a solid understanding of jQuery and find it to be quite useful. My idea is to suggest to my team the utilization of jQuery for direct callin ...

Tips on avoiding a page reload following a form submission using JQuery

Currently developing a website for my app development project, I've encountered an unusual issue. Utilizing some JQuery to transfer form data to a php page called 'process.php' and then add it to my database. The strange part is that the pa ...

Unexpected quirks noticed in the .html() function with jQuery and JavaScript

I have this straightforward HTML code: <td id="comment_td"> </td>. Notice the two spaces inside the td tags. I am checking the content of the td element like this: if (!$('#comment_td').html()) { $('#comment_td').html( ...

Do we need to use aria-labelledby if we already have label and input associated with "for" and "id"?

Here is the HTML structure for the Text Field component from Adobe Spectrum: The <label> element has a for attribute and the <input> has an id which allows screen readers to read out the label when the input is focused. So, why is aria-label ...

Position a div to float in the top right corner without overlapping its sibling header

Is there a way to position a div in the top right corner of a section without overlapping the text of a h1? This is the HTML code: <section> <h1>some long long long long header, a whole line, 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6</h1> < ...

Having trouble fetching information from form in a basic node.js program

Hey, so I'm not exactly a pro at backend development, but I gave it a shot and came up with this straightforward program: Here's my HTML file: <!DOCTYPE html> <head></head> <body> <form action = "http://lo ...

The Select2 ajax process runs twice

I am encountering an issue with a script I have that retrieves data from the backend to populate a select2 dropdown. The problem is that the ajax call is being triggered twice every time, which is not the desired behavior. I'm unsure of what mistake I ...

Arrange CSS to distribute list items across two rows with an unlimited number of items

I need my list items to be arranged in 2 rows like the following: item 1 item 3 item 5 item 7 item 9 .... item 2 item 4 item 6 item 8 ...... My CSS skills are not great, so I am struggling to find a solution for this. I have at ...

Ways to insert user data into a hidden input field

I am facing an issue with the input field on my website. Users can enter their desired input, and this data is copied into a hidden input field. However, the problem arises when new data replaces the old data. This is where I copy all the data: $('# ...

A guide on using key arrows in JavaScript to navigate and focus on elements

When working on my HTML project, I have a list of elements that I want to be able to select using the arrow keys. I've included my code here for reference: [http://jsfiddle.net/T8S7c/] What I'm trying to achieve is when the arrow keys are press ...

How to align text to the right with ellipsis and button in a ReactJS component

In a specific scenario, I need to display a button on the right corner of the header. The selected filter value should appear next to the filter button like this: | Between 01/23/2018 and 07/30/2018 {button}| As the user changes the screen size, I want to ...