Slideshow Control problem, one side does not work
Hi! I am new to jQuery and am trying to adapt a slideshow to fit my layout. I have one end of the slideshow working fine, as you can scroll left with no issue. However, on the right control, the button does not seem to be clickable.
The link to the page is
here.
Here is the template page's 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" />
- <!-- TemplateBeginEditable name="doctitle" -->
- <title>DAVIDE MARCHETTI ARCHITETTO</title>
- <!-- TemplateEndEditable -->
- <style type="text/css">
- <!--
- /**
- * Slideshow style rules.
- */
- #slideshow {
- margin: 0 auto;
- width: 702px;
- height: 346px;
-
- position: relative;
- background-image: url(../images/Davide-border.png);
- }
- #slideshow #slidesContainer {
- margin: 23px auto;
- width: 702px;
- height: 323px; /* allow scrollbar */
- position: relative;
- }
- /**
- * Slideshow controls style rules.
- */
- .control {
- display:block;
- width:39px;
- height:39px;
- text-indent:-10000px;
- position:absolute;
- cursor: pointer;
- }
- #leftControl {
- top:0;
- left:650px;
- background:transparent url(images/left_control.png) no-repeat 0 0;
- }
- #rightControl {
- top:0;
- right:-40px;
- background:transparent url(images/right_control.png) no-repeat 0 0;
- }
- #slideshow #slidesContainer .slide {
- margin:23px auto;
- width:700px; /* reduce by 20 pixels of #slidesContainer to avoid horizontal scroll */
- height:300px;
- }
- /**
- * Style rules for Demo page
- */
- * {
- margin: 0;
- padding: 0;
- color: #000;
- font-family: "Courier New", Courier, monospace;
- font-size: xx-small;
- font-style: normal;
- font-weight: normal;
- font-variant: normal;
- }
- a {
- color: #fff;
- font-weight:bold;
- text-decoration:none;
- }
- a:hover {
- text-decoration:underline;
- }
- body {
- background:#FFFFFF;
- }
- #pageContainer {
- margin:0 auto;
- width:960px;
- }
- #pageContainer h1 {
- display:block;
- width:960px;
- height:114px;
- background:#FFFFFF;
- text-indent: -10000px;
- }
- .slide h2, .slide p {
- margin:15px;
- }
- .slide h2 {
- font:italic 24px Georgia, "Times New Roman", Times, serif;
- color:#ccc;
- letter-spacing:-1px;
- }
- .slide img {
- float:right;
- margin:0 15px;
- }
- #footer {
- height:100px;
- }
- #footer p {
- margin: 30px auto 0 auto;
- display: block;
- width: 703px;
- height: 40px;
- color: #000;
- font-family: "Courier New", Courier, monospace;
- }
- body,td,th {
- color: #000000;
- }
- #pageContainer #footer p a {
- color: #000;
- }
- #apDiv1 {
- position: absolute;
- width: 32px;
- height: 1px;
- z-index: 1;
- left: 130px;
- top: 441px;
- }
- #apDiv2 {
- position: absolute;
- width: 22px;
- height: 4px;
- z-index: 1;
- left: 0px;
- top: 327px;
- }
- #apDiv3 {
- position: absolute;
- width: 3px;
- height: 0px;
- z-index: 1;
- left: 214px;
- top: 328px;
- }
- #apDiv4 {
- position: absolute;
- width: 0px;
- height: 0px;
- z-index: 1;
- left: 442px;
- top: 328px;
- }
- #apDiv5 {
- position: absolute;
- width: 0px;
- height: 4px;
- z-index: 1;
- left: 655px;
- top: 328px;
- }
- #apDiv6 {
- position: absolute;
- width: 49px;
- height: 3px;
- z-index: 1;
- left: 1px;
- top: 0px;
- }
- -->
- </style>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- var currentPosition = 0;
- var slideWidth = 723;
- var slides = $('.slide');
- var numberOfSlides = slides.length;
- // Remove scrollbar in JS
- $('#slidesContainer').css('overflow', 'hidden');
- // Wrap all .slides with #slideInner div
- slides
- .wrapAll('<div id="slideInner"></div>')
- // Float left to display horizontally, readjust .slides width
- .css({
- 'float' : 'left',
- 'width' : slideWidth
- });
- // Set #slideInner width equal to total width of all slides
- $('#slideInner').css('width', slideWidth * numberOfSlides);
- // Insert controls in the DOM
- $('#slideshow')
- .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
- .append('<span class="control" id="rightControl">Clicking moves right</span>');
- // Hide left arrow control on first load
- manageControls(currentPosition);
-
- $('slideInner').animate({
- 'marginLeft' : slideWidth*(-currentPosition)
- });
- // Create event listeners for .controls clicks
- $('.control')
- .bind('click', function(){
- // Determine new position
- currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
-
- // Hide / show controls
- manageControls(currentPosition);
- // Move slideInner using margin-left
- $('#slideInner').animate({
- 'marginLeft' : slideWidth*(-currentPosition)
- });
- });
- // manageControls: Hides and Shows controls depending on currentPosition
- function manageControls(position){
- // Hide left arrow if position is first slide
- if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
- // Hide right arrow if position is last slide
- if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
- }
- });
- function autoshow(){
- //alert(‘start’);
- currentPosition = currentPosition+1 ;
- if(currentPosition==numberOfSlides){
- currentPosition=0;
- }
- // Hide / show controls
- manageControls(currentPosition);
- // Move slideInner using margin-left
- $('#slideInner').animate({
- 'marginLeft' : slideWidth*(-currentPosition)
- });
- setTimeout(autoshow, 5000);
- }
- </script>
- <!-- TemplateBeginEditable name="head" -->
- <!-- TemplateEndEditable -->
- </head>
- <body text="#000000">
- <div id="pageContainer">
- <h1><a href="">Davide Marchetti Architetto</a></h1>
- <!-- Slideshow HTML -->
-
- <div id="slideshow"><!-- TemplateBeginEditable name="EditRegion1" -->
-
- <div id="apDiv6"><a href="index.html"><img src="../images/hd-main.png" width="178" height="20" /></a></div>
- <div id="apDiv5"><a href="contact.html"><img src="../images/hd-contact.png" width="47" height="19" usemap="#Map2" border="0" />
- <map name="Map2" id="Map2">
- <area shape="rect" coords="-5,-1,62,30" href="contact.html" />
- </map>
- </a></div>
- <div id="apDiv4"><a href="projects.html"><img src="../images/hd-projects.png" width="55" height="19" usemap="#Map" border="0" />
- <map name="Map" id="Map">
- <area shape="rect" coords="-2,-1,60,19" href="#" />
- </map>
- </a></div>
- <div id="apDiv3"><a href="studio.html"><img src="../images/hd-studio.png" width="41" height="19" usemap="#studioMap" longdesc="studio.html" border="0" />
- <map name="studioMap" id="studioMap">
- <area shape="rect" coords="-8,-2,78,22" href="#" target="studio.html" />
- </map>
- </a></div>
- <div id="apDiv2"><a href="news.html"><img src="../images/hd-news.png" width="78" height="19" usemap="#newsMap" border="0" />
- <map name="newsMap" id="newsMap">
- <area shape="rect" coords="-12,-10,164,65" href="#" />
- </map>
-
- </a></div>
- <div id="slidesContainer">
- <div class="slide">
- <!-- IMAGE ONE -->
- </div>
- <div class="slide">
- <!-- IMAGE ONE -->
- </div>
- <div class="slide">
- <!-- IMAGE ONE -->
- </div>
- <div class="slide">
- <!-- IMAGE ONE -->
- </div>
- </div>
- <!-- TemplateEndEditable --></div>
- <!-- Slideshow HTML -->
- <div id="footer">
- <p align="right"><a href="http://erinpellegrino.com">Website by Erin Pellegrino</a></p>
- </div>
-
- </div>
- </body>
- </html>
Above is the code.