Guide to creating a zoom-in, fade-out slideshow with jquery

Here is my code, but it's not functioning correctly: Here is my style sheet

<style>
body
{
overflow:hidden;
}
div
{
position:absolute;
top:-330px;
left:-50px;
}
#slideshow img
{
position:absolute;
z-index:8;
}
#slideshow img.active
{
z-index:10;
transition-delay:5s;
transition:all 1s ease;
transform:scale(1.25);
}
#slideshow img.last-active
{
z-index:9;
}
</style>
</head>

Body statement

<body>
<div id="slideshow">
<img src="C:\Documents and Settings\Aravind.P\Desktop\JQuery\Matt Wiebe_Manhattan Skyline_akRhRQ.jpg" class="active">
<img src="C:\Documents and Settings\Aravind.P\Desktop\JQuery\Ray_A New Day_YkFhSGU.jpg">
<img src="C:\Documents and Settings\Aravind.P\Desktop\JQuery\Luke Ma_Shinjuku Skyline - Sony A7r_a0dkRw.jpg">
</div>

Here is my jquery where I created a slideshow by adding classes

<script>
function slideShow()
{
var $active=$("#slideshow img.active");
var $next=$active.next().length ? $active.next():$("#slideshow          img:first");
$active.addClass("last-active");
$next
.addClass("active");
$active.removeClass("active anim last-active");
}
$(function()
{
setInterval("slideShow()",5000);
});
</script>

In the script above, I am checking if there is a next image, and if not, pointing back to the first image

Answer №1

If you want to identify the last image, you can simply assign a class to it:

 $("img:last-child").addClass("last");//add a class to the last image

You can then determine if an img element has this class to confirm that it is indeed the last image:

    if ($("img").hasClass("last")) {
     $(img:last-child).removeClass("active");
     $(img:first-child).addClass("active");
}

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

Verification of date in Bootstrap datepicker

Whenever I manually input a date into the field and then click outside of it, the date value becomes empty if the format is incorrect. I've been attempting to simulate an "enter" event when clicking outside of the input field so that the datepicker c ...

Out of nowhere, the functionality for printing labels in html/css has stopped

For over 3 years, a website has been successfully printing labels for shoes. However, the functionality suddenly broke two days ago, specifically the labels or page-break-after feature stopped working correctly. Despite searching online, I was unable to d ...

What is causing the unexpected impact of the "Product Quick View" JavaScript plugin on divs that are not being activated by user interaction?

As a newcomer to web design, I have implemented the "Product-Quick-View" plugin from CodyHouse on my website. Upon clicking the DEMO button and inspecting the code, you will find the following: <body> <header> <h1>Product Q ...

Creating pages or tabs within a table using HTML5 and Angular is a simple and effective way to organize

I have a REST response that returns around 500 records. These records are being displayed in an Angular table. I would like to add customization options for the user, allowing them to choose to display 10/20/30... records per page. Additionally, I want to ...

Remove the concluding statement from the HTML string if it exceeds the capacity of the iPhone's webView

I have an array of content with certain sections in bold. The bold parts can be located anywhere within the text, so I am utilizing a webView to display an HTML string with appropriate bold tags. However, I am encountering issues where the webViews do not ...

What steps can be taken to remove a server-side validation error message once the user has inputted the correct value?

I'm facing an issue with server-side validation messages on my form, which includes fields for Name, Mobile, Email, and Message. While JQuery validation works fine, clearing the error message after user input is causing a problem. Using AJAX to submi ...

The text displayed on the image is experiencing fluctuations

I am experiencing an issue on my website where the post text fluctuates rapidly when the mouse hovers over the image. I have a site where I display the post text on mouseover of the image. Can someone please help me solve this problem? You can test it by ...

Delay the closure of a window by utilizing a straightforward method when selecting the "X - CLOSE" option with the following code: `<a href="javascript:window.open('', '_self').close();">X - CLOSE</a>`

I need to implement a delay when users click on the link to close a window. The purpose of this delay is to allow time for playing random "signoff" audio files, such as "Thanks!" or "See you next time!". Currently, without the delay, the audio stops abrupt ...

Utilizing jQuery to load a dynamic background image

Looking to use jQuery to asynchronously load a background image without stretching or resizing on reload. The goal is to position it in the bottom right corner of the body and possibly have it fade in upon loading. Any tips or suggestions for achieving t ...

Guide on implementing Observables in Angular 2+ to update a single entry in a table in real-time

I'm facing a challenge with my Angular4 and Node.js application. I have a table that displays data with 7 columns using *ngFor. The issue arises when I need to update the last column dynamically and in real-time. Specifically, I want to show a green c ...

Troubleshooting Firefox's inability to properly utilize jQuery's scrollTop() function on the 'body' element

I'm puzzled as to why the scrollTop() jquery function isn't functioning properly on the 'body' element in Firefox. $('body').scrollTop(0); To resolve this issue, I ended up using: $(window).scrollTop(0); The jquery documen ...

"Encountering an error of undefined index when dealing with multiple file

I've encounter an issue with this code but can't seem to figure out what's wrong. Any help would be greatly appreciated. Kindly refrain from marking it as a duplicate too quickly; I've already gone through similar questions without find ...

Can the text within an li element be accessed using Xpath even with varying attributes?

Instead of directly using: driver.FindElement(By.XPath("//ul[3]/li/ul/li[7]")).Text I am exploring ways to retrieve the text by utilizing Xpath along with different attributes like text(), contains(), and so on. //ul[3]/li/ul/li//[text()='My Data&a ...

"Clicking on a link inside a div element using the onclick

Hey there! I'm having an issue with a div that contains a link with an onclick event (see the code snippet). Inside this div, there is another link that goes to a different page than the div itself. The code works perfectly fine in IE, Chrome, and Fir ...

send multiple textbox values to controller in CodeIgniter

I am new to Codeigniter and I'm facing some difficulties in understanding how to accomplish a task. In my view page, there are five rows generated using a for loop. Each row consists of two select boxes and two input boxes. I don't know how to re ...

"Arranging elements with identical class in a single column but on separate rows using CSS grid - a step-by-step guide

I'm facing an issue with organizing choices and matches in columns using grid CSS. Currently, the match column is overlapping with the choice column. Here is how it is coded at the moment: .grid{ display:grid; grid-template-columns: 1fr 1 ...

Centralize and confine the menu division

I have been working on creating a hover menu using CSS and Bootstrap, specifically for flex grid layouts. However, I have run into an issue where my menu is only as wide as its parent div. Furthermore, I am struggling to center the hover menu relative to ...

Having trouble sending the "@" symbol as a variable in jQuery

Just starting out with jquery, but picking it up quickly. I've been using $.post to send form values from html to a php file. Everything was working perfectly until an email address with the "@" symbol was entered (which is expected). Then things sta ...

Guide to Embedding a SQL Table into an HTML Table

I need to set up a table within my current webpage to showcase a list of movies along with their genres. Welcome to my Movies page. The index.php file contains all the necessary database credentials and establishes the connection. <?php session_start( ...

unresolved string constant issue with a django template command

I encountered an issue with the code snippet below, which is resulting in an unterminated string literal error: $(function() { $('#addDropdown').click(function() { var $d = $('{{ form |bootstrap }}').fadeIn(). ...