Solved

jQuery automatic slideshow jumps

Posted on 2013-01-02
2
462 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
ID: 38738451
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
ID: 38738460
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Google Maps API and PHP 25 35
Client Validating 2 date fields, required & comparison 1 29
asp.net mvc5 6 17
ajax jquery 3 12
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

832 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