Solved

JQuery slideshow script is not working

Posted on 2015-02-17
2
186 Views
Last Modified: 2015-02-18
I followed a video I found on YouTube to make a slideshow using JQuery (https://www.youtube.com/watch?v=5_P3Auq-U8c).  I'm not sure what I am doing wrong but my pictures do not display.  Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Slide Show Test</title>
    <style type="text/css">
        .slider 
        {
	        width: 600px;
	        height: 200px;
	        overflow: hidden;
	        margin: 30px auto;	
	        /*padding: 0;
	        background-color: #006699; /*#005daa;*/
	        /*float: left;*/
        }
        .slider img 
        {
            width: 600px;
            height: 200px;
            display: none;
        }
    </style>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
    <script type="text/javascript">
        function Slider() {
            $(".slider#1").show("fade", 500);
            $(".slider#1").delay(5500).hide("slide", { direction: "left" }, 500);

            var sc = $(".slider img").size();
            var count = 2;

            setInterval(function(){
                $(".slider#"+count).show("slide", { direction: "right"}, 500);
                $(".slider#"+count).delay(5500).hide("slide", { direction: "left" }, 500);

                if (count == sc){
                    count = 1;
                }else{
                    count = count + 1;
                }
            }, 6500);
        }
    
    </script>
</head>
<body onload="Slider();">
        <div class="slider">
            <img src="images\HomePagePics\Altar_2-24-11.JPG" alt="ABVM" id="1" />
            <img src="images\HomePagePics\Inside_2-24-11.JPG" alt="ABVM" id="2" />
            <img src="images\HomePagePics\Lt_Relief_2-24-11.JPG" alt="ABVM" id="3" />
        </div>  

</body>
</html>

Open in new window


If I remove this line from the .slider img style, the first picture displays:             display: none;
However, the images do not switch.

Can anyone help me figure out what I am doing wrong?
0
Comment
Question by:dyarosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40615771
You need a space between the slider class and the image id in the jQuery selector: $(".slider #1")
function Slider() {
            $(".slider #1").show("fade", 500);
            $(".slider #1").delay(5500).hide("slide", { direction: "left" }, 500);

            var sc = $(".slider img").size();
            var count = 2;

            setInterval(function(){
                $(".slider #"+count).show("slide", { direction: "right"}, 500);
                $(".slider #"+count).delay(5500).hide("slide", { direction: "left" }, 500);

                if (count == sc){
                    count = 1;
                }else{
                    count = count + 1;
                }
            }, 6500);
        }

Open in new window

0
 

Author Closing Comment

by:dyarosh
ID: 40616233
Thank you.  That solved the problem!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question