Solved

jQuery automatic slideshow jumps

Posted on 2013-01-02
2
459 Views
Last Modified: 2013-01-02
I have a jQuery example that I am trying and it's not quite right. The images are automatically going to the next one, but when the next image is fading in, it pushes the previous image down instead of them fading in/out on top of each other.

'*** CODE ****
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="JQuerySlideShow2.aspx.vb" Inherits="test_JQuerySlideShow2" %>

<!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 runat="server">
    <title>Untitled Page</title>

  <style type="text/javascript">
    #slideshow {
                margin: 80px auto;
                position: relative;
                width: 240px;
                height: 240px;
                padding: 10px;
                box-shadow: 0 0 20px rgba(0,0,0,0.4);
            }
            
            #slideshow > div {
                position: absolute;
                top: 10px;
                left: 10px;
                right: 10px;
                bottom: 10px;
            }
  </style>
 
  <script src="../scripts/jquery-1.8.3.min.js" type="text/javascript"></script>

  <script type="text/javascript">
            $(document).ready(function() {
            
                  $("#slideshow > div:gt(0)").hide();
      
                  setInterval(function() {
                    $('#slideshow > div:first')
                      .fadeOut(1000)
                      .next()
                      .fadeIn(1000)
                      .end()
                      .appendTo('#slideshow');
                  },  3000);
                  
            });
  </script>
 
</head>

<body>
    <form id="form1" runat="server">
   
    <div id="slideshow">
      <div>
        <img src="img/img_slide_01.jpg" />
      </div>
     
      <div>
        <img src="img/img_slide_02.jpg" />
      </div>

      <div>
        Pretty cool eh; This slide is proof the content can change.
      </div>
    </div>
   
    </form>
</body>
</html>
0
Comment
Question by:prothera
2 Comments
 
LVL 16

Accepted Solution

by:
hankknight earned 500 total points
Comment Utility
The problem is with this line:
<style type="text/javascript">

Open in new window

It should be:
<style type="text/css">

Open in new window

That typo causes your CSS not to work properly and that causes the jump.
0
 

Author Comment

by:prothera
Comment Utility
That's awesome! I thought it was something silly like that. Thanks a million. You're talking about the first occurrence of that.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now