Implementing a delay between two div elements using jQuery

I have two Divs with the class "sliced", each containing three images with the class "tile". When I animate using jQuery, I am unable to add a delay between the "sliced" classes. However, I have successfully added a delay between the "tile" classes.

index.html

<!DOCTYPE html> 
     <html>
        <head>
            <title>Testing Scripts</title>
            <link rel="stylesheet" type="text/css" href="style.css">
        </head>
        <body>




        <div id="slider-wrap">
            <div class="sliced">

                    <div class="tile"><img src="http://imageshack.us/a/img545/9813/58zj.jpg" alt"1"></div>
                    <div class="tile tile1"><img src="http://imageshack.us/a/img818/5776/8ik6.jpg" alt"1"></div>
                    <div class="tile tile2"><img src="http://imageshack.us/a/img18/6017/rue6.jpg" alt"1"></div>
            </div>  
            <div class="sliced " >

                    <div class="tile"><img src="http://imageshack.us/a/img163/6131/ld3f.jpg" alt"1"></div>
                    <div class="tile tile1"><img src="http://imageshack.us/a/img838/4102/h0nv.jpg" alt"1"></div>
                    <div class="tile tile2"><img src="http://imageshack.us/a/img833/6500/dp5e.jpg" alt"1"></div>
            </div>  
         </div>   


         </div>
        <script src="jQuery.js"></script>
        <script src="jquery.easing.1.3.js"></script>
        <script src="script.js"></script>
        <script>$('.sliced').slider();</script><!--Calling plugin with   -->
        </body> 
     </html>

CSS

body {
    width: 960px;
    margin: 100px auto;
    font-family: helvetica;
    font-size: 20px;
 }

#animate {
    width: 100px;
    height: 30px;
    margin-bottom: 10px;
    font-size: 16px;
}
.sliced {
    position: relative;
    margin: 5px 5px;
    width: 900px;
    height: 200px;
    border: 2px solid black;
    }
.box {
    width: 600px;
    border: 2px solid rgba(0,0,0,.05);
    padding: 10px 10px;
}

img {
    width: 270px;
    height: 150px;

}
.tile {
    position: absolute;
    float: left;
    margin: 25px 15px;
}
.tile1 {

    left: 280px;

}
.tile2 {

    left: 560px;

}

JScript:-

function Slider(element){
    var $element = $(element), //Jquery Object of .sliced class
        $tiles = $element.find('.tile');  //$tiles contains all .tile class as jquery Object
        $.each($tiles,function(index,value){ 
               setTimeout(function(){
                $(value).fadeOut(1000);
                },1000*index);

        });

} 

$.fn.slider = function(){   
       //This stores all .sliced class as Jquery object                                      
    return this.each(function(){  //Iterating over each class provided 
        var slider = new Slider(this);  //Slider is constructor function
        //console.log(slider);
    });
}

Answer №1

At long last, after numerous attempts and experiments, I finally managed to figure it out on my own

JavaScript:-

function Slideshow(element, index){
    var $element = $(element), //Jquery Object of .sliced class
        $tiles = $element.find('.tile'),//$tiles contains all .tile class as jquery Object
        delay = 5000;  //Delay between two divs
        
        setTimeout(function(){
             $.each($tiles,function(index, value){ 
               setTimeout(function(){
                $(value).fadeOut(1000);
                },1000*index);
          });
        },delay*index);
} 

$.fn.slideshow = function(){   
       //This stores all .sliced class as Jquery object                                      
    return this.each(function(index){  //Iterating over each class provided 
        var slideshow = new Slideshow(this,index);  //Slideshow is constructor function
        //console.log(slideshow);
    });
}

Answer №2

How about considering this suggestion:

$( "div" ).click(function() {
  $( this ).addClass( "big-blue", 1000, "easeOutBounce" );
});

Do you think this could be beneficial?

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

creating a personalized dropdown menu with react javascript

Is it possible to create a chip in a single select dropdown in React? In a multi-select dropdown, a chip is created as shown in the example below. Can we achieve the same effect in a single selection dropdown? const DropdownExampleClearableMultiple = () = ...

Images within inline blocks appear to be extending beyond their containing div as though they are

When I check my website in various browsers such as Firefox, IE, Edge, and Safari, I noticed that the images in the "My Specialties" section of the left column are extending outside of the div instead of fitting within it. This problem also occurs in Chrom ...

Why is it necessary to define a property outside the constructor in Typescript, when in Javascript I wouldn't have to do that?

When working with Javascript, creating a class like the one below allows us to avoid declaring and initializing a property named logs outside of the constructor: class Logger { constructor() { this.logs = []; } } However, transitioning to TypeScri ...

Troubles arise when utilizing getChannelData to configure socket.io in web audio,

I'm facing a problem where my connection gets disconnected as soon as I execute the code source.buffer.getChannelData(0).set(audio);. This issue occurs when I transcode an audio file and send the audio buffer to the client using socket.io for playback ...

What could be the reason behind receiving a TypeError upon refreshing the page, where it claims that a state is not found even though that may not be the actual situation?

Within my application, I have a component called Wall. Users are redirected to the Wall component after successfully logging in from the Login component. In the Wall component, I am retrieving and displaying the user's name that they used during regis ...

What is the best method for incorporating card components from Stripe into a Vue.js application?

I am currently facing an issue with implementing Stripe in my Vue.js project. Despite following the documentation provided, I am encountering errors such as "stripe is not defined" and "Uncaught ReferenceError: h is not defined". Initially, I created a pa ...

Tips for creating a partial matching filter on an array using elements from a separate array

My goal is to filter an array by finding partial matches from another array. To illustrate, consider the following arrays: Array1 = categories: 292300, categories: 300, categories: 292500280 Array2 = 300, 498 After filtering, ...

A Guide to Accessing Numbered Properties within an Object

I am working with a large Object that has over 700 properties, all numbered. How can I efficiently iterate through each of these numbered properties? { '0': { emails: { categorized: [Object], all: [Object], primary: &a ...

Tips on adjusting the height of divs in a simple layout

I'm trying to make two divs fill the page with a ratio of 70% and 30%. However, I don't want to set the size of the "html" or "body" elements. How can I achieve this without affecting the height of the text within the divs? Currently, it only dis ...

Unsuccessful response from an AJAX callback function

Issue: I am able to successfully pass a value to the ajax method and execute a Select SQL query (results visible in Network tab), but I never receive any results back (I expect an alert saying "Success"). What could be causing this issue? HTML: function ...

What advantages does KnockoutJS offer over AngularJS?

Can KnockoutJS offer a unique feature that rivals or exceeds those of AngularJS? ...

What occurs when a jQuery dynamically generated element with the specified ID is attempted to be created if the element already exists

var newWindow = $("<div id='newmsgwindow'/>").anotherWidget({ setting1: true, setting2: someVariableWithDynamicValue }); If the above code is run multiple times, what will occur? Will the element with id #newmsgwindow be f ...

What is the method for setting tabstops in XHTML?

Is there a way to create a tabstop in an xhtml webpage without using the "&nbsp;" method? I want to avoid putting a space between the ampersand and 'n'. Any suggestions? Edit: My initial post did not display the &nbsp;. I am looking for ...

Having trouble retrieving the YouTube channel name using XPath node in Selenium and TestNG

My current task involves navigating to the YouTube website, entering the search term "qtp," and clicking on the Search button. Once on the results page, I need to extract the Channel Name. To achieve this, I used Firebug to identify the path for the first ...

Implement a default dropdown menu that displays the current month using Angular and TypeScript

I am looking to implement a dropdown that initially displays the current month. Here is the code snippet I have used: <p-dropdown [options]="months" [filter]="false" filterBy="nombre" [showClear] ...

Morris.js is throwing an error message, stating "Uncaught TypeError: Unable to access the 'label' property as it

I have successfully implemented a bar chart along with a date picker using Bootstrap. The bar chart loads data accurately when selecting a specific day. However, upon inspecting the developer tools, I encounter the following errors: Uncaught Type Error: C ...

Building a personalized Directive in Angular: A step-by-step guide

I attempted to implement a sample pagination feature by creating a directive like the following (I am not sure if it is correct): (function() { app.directive("myPagination", function() { return { restrict: 'E', templateUrl: & ...

Styling Dropdown Options Based on Conditions in React

In my current project, I am attempting to modify the className of selected items within a mapped array using another array (this.props.notPressAble). The reason for this is because I want certain objects in the array to have a different CSS style. handleOp ...

Keep your data safe and protected within a Node CLI application

Currently developing a NodeJS command-line application that interacts with an API to provide data to users. To access the public API, users need an API token. The CLI will be globally installed on users' machines using npm i -g super-cool-api-cli. Up ...

Issue with Material UI React: Navbar does not properly align the box to the right side

I'm facing an issue with my navbar that is supposed to align all the page options to the right. Despite using a flexbox layout and trying different alignment properties like alignSelf: end, the text only moves slightly downwards instead of aligning pr ...