A simple Auto Playing Slider using JQuery

This tutorial will teach you how to create an auto-playing slider using jQuery, HTML, and CSS.

Auto-Playing Slider in jQuery

First, let’s create the HTML code. Note that you will have to replace the images below with images of your choice.

<div class="container">
    <div id="MySlideShow">
        <div style="width: 50px">
            <img src="\images\1.jpg">
            <img src="\images\2.jpg">
            <img src="\images\3.jpg">


Now, add the CSS class below to your HTML file or a separate file if you prefer.

    #MySlideShow {
        margin: 50px 50px 50px 50px;
        position: relative;
        width: 250px;
        height: 250px;

        #MySlideShow > div {
            position: absolute;

            #MySlideShow > div > img {
                width: 300px;
                height: 300px;

And, the jQuery code, which will wait to fade out an image, then fades in the next one.

    $(document).ready(function () {

        $("#MySlideShow > div:gt(0)").hide();

        setInterval(function () {
            $('#MySlideShow > div:first')
        }, 5000);


After running your application, the output should be similar to the Slider below: