1

I am new at jQuery and I'm trying to create a slideshow. I created it but when the timer change my picture, all the page seems to be refreshed.

HTML Example:

<div class="slide">
    <img id="scroll_image" src="img/rooms/suite5.jpg" width="1000" height="350" alt="hotel-suite-1" class="show" />
    <img id="scroll_image" src="img/rooms/suite1.jpg" width="1000" height="350" alt="hotel-suite-2" />
    <img id="scroll_image" src="img/rooms/suite2.jpg" width="1000" height="350" alt="hotel-suite-3" />
    <img id="scroll_image" src="img/rooms/suite3.jpg" width="1000" height="350" alt="hotel-suite-4" />
    <img id="scroll_image" src="img/rooms/suite4.jpg" width="1000" height="350" alt="hotel-suite-5" />
</div><!--end of slide-->

jQuery Example:

$(document).ready(function() {
    slideShow();
});

function slideShow() {
    var current = $('.slide .show');
    var next = current.next().length ? current.next() : current.parent().children(':first');
    current.hide().removeClass('show');
    next.fadeIn().addClass('show');
    setTimeout(slideShow, 6000);
}

You can see what i mean if you click here, scroll down the page and wait for the timer to change the image!?

Ilia Ross
  • 13,086
  • 11
  • 53
  • 88
pant
  • 30
  • 1
  • 6
  • You should take the time to format the code in your question or others wont find the time to answer. – AfromanJ Nov 08 '13 at 17:42
  • What browser are you using ? Anyway why don't you use JQuery cycle plugin ?Is much easier to use:) –  Nov 08 '13 at 17:52
  • @JamieRead Sorry for the bad code but i didnt know that i can format it here. Its first time here. Thanks for replying me. – pant Nov 08 '13 at 18:22
  • @Zsigoveny As for the browser iam using chrome but i test it at firefox also and do the same thing – pant Nov 08 '13 at 18:26

1 Answers1

1

It's not your page that is refreshing. Your page is for some reason srolling everytime you slide a image.

Your problem is the jquery-min-1.5.1.js you are using.

Update your jQuery to the latest version and the problem will be solved :) You can also use the latest external jquery link:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

source : Is there a link to the "latest" jQuery library on Google APIs?


jsFiddle With your jQuery version

jsFiddle With latest version (used the latest external link as shown above)

Goodluck!

Community
  • 1
  • 1
nkmol
  • 8,025
  • 3
  • 30
  • 51
  • i cant vote. To vote up i need at least 15 reputation. Your solution really works – pant Nov 08 '13 at 18:42
  • I accept now? Its my first time here and i dont know if i do things right. – pant Nov 08 '13 at 18:44
  • Hehe no problem :) yea you have accepted this answer. I'm just glad i could help :) Goodluck further on! – nkmol Nov 08 '13 at 18:44