Jump to content

jQuery Slidshow help


condoravenue

Recommended Posts

I have one slideshow that goes through images only:

 

<!doctype HTML>
<html>
<head>

<style>
.fadein { position:relative; height:332px; width:500px; top: 140px; margin: auto;}
.fadein img { position:absolute; left:0; top:0; height:332px; width:500px; }

</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
delay = 1500;
$(function(){$('.fadein img').hide(); $('.fadein :first-child').fadeIn(function(){slide_show();});});

function slide_show(){
$('.fadein :first-child').delay(delay).fadeOut().appendTo('.fadein');
$('.fadein :nth-child(1)').delay(delay).fadeIn(function () {slide_show();});
}
</script>

</head>
<body>
<div class="fadein">
<img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg">
<img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg">
<img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg">
</div>
</body>
</html>

 

But I tried to make it work with div's instead of images:

 

<!doctype HTML>
<html>
<head>

<style>
.fadein { position:relative; height:332px; width:800px; top: 140px; margin: auto;}
.fadein div { position:absolute; left:0; top:0; height:332px; width:800px; text-align: right; background-repeat: no-repeat;}
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
delay = 2500;
$(function(){$('.fadein div').hide(); $('.fadein :first-child').fadeIn(function(){slide_show();});});

function slide_show(){
$('.fadein :first-child').delay(delay).fadeOut().appendTo('.fadein');
$('.fadein :nth-child(1)').delay(delay).fadeIn(function () {slide_show();});
}
</script>

</head>
<body>
<div class="fadein">
<div class = "slide" style = "background-image: url('http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg');"><h1>One Heading</h1><p>some extra text.</p></div>
<div class = "slide" style = "background-image: url('http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg');"><h1>Two Heading</h1></div>
<div class = "slide" style = "background-image: url('http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg');"><h1>Three Heading</h1></div>
</div>
</body>
</html>

 

This second code doesn't work. It works without the <h1> tags in each div. How can I make this work?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.