/    Sign up×
Community /Pin to ProfileBookmark

How to loop an image slider

Hello,
I’m having a little bit of trouble with an image slider I am doing. I need it to loop to the beginning of the slide show when it reaches the end of the images

Here is my markup:

[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>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>Twin Tiers Technologies – Image Slider</title>
<link href=”styles.css” rel=”stylesheet” type=”text/css” />
<script src=”jquery-1.4.4.min.js” type=”text/javascript”></script>
<script src=”scripts.js” type=”text/javascript”></script>
</head>

<body>
<div id=”wrapper”>
<div id=”container”>
<div id=”mask”>
<div id=”slider”>
<div id=”images”>
<img src=”images/web.jpg” alt=”Websites” />
<img src=”images/mims.jpg” alt=”Mortuary Information Management System” />
<img src=”images/cims.jpg” alt=”Cremetory Information Managment System” />
<img src=”images/motv.jpg” alt=”Memories On TV” />
<img src=”images/web-casting.jpg” alt=”Web Casting” />
<img src=”images/support.jpg” alt=”Support” />
</div>
</div>
</div>
</div>
<img src=”images/arrow-back.png” id=”back” />
<img src=”images/arrow-forward.png” id=”forward” />
</div>

</body>
</html>
[/CODE]

Here is my CSS

[CODE]@charset “UTF-8”;
/* CSS Document */

#wrapper{
width: 902px;
margin: 200px auto;
}

#container{
width: 861px;
height: 225px;
margin: 0 auto;
background-image:url(images/slider-bg.png);
background-repeat: no-repeat;
}

#mask{
width: 731px;
height: 225px;
margin: 20px auto;
overflow: hidden;
}

#slider{
width: 2000px;
}

#slider img{
float: left;
padding: 5px;
}

#back{
float: left;
position: relative;
top: -140px;
}

#forward{
float: right;
position: relative;
top: -140px;
}

#images{
position: relative;
float: left;
}[/CODE]

and finally my script

[CODE]// JavaScript Document

$(document).ready(function () {

$(‘#back’).click(function (){

$(‘#images’).animate({“left”: “+=757px”}, 1000);
})

$(‘#forward’).click(function () {

$(‘#images’).animate({“left”: “-=757px”}, 1000);

var $next = $active.next().length ? $active.next()
: $(‘#slideshow IMG:first’);

})

})[/CODE]

Anyone have any suggestions?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@omnicityDec 17.2010 — I don't use JQuery very often, but surely you just need to tag something like:

[CODE]
$('#images').animate({"left": "=0"}, 1000);
[/CODE]


on to your last condition?
×

Success!

Help @ExplosiveHippo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...