Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jQuery automatic slideshow jumps

Posted on 2013-01-02
2
Medium Priority
?
470 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

971 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