views:

140

answers:

3

I have five divs on my page (#art #fashion, #self, #nightlife, #community). right now, when you mouseover them, they load page content into another container div (#flyer).

I would like the flyer content to cycle every 5 seconds or so.

So, instead of having to mouseover those 5 divs, it should just automatically go.

does that make sense?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript"> 
$(document).ready(function() { 
        $("#art").mouseover(function(){ $('#flyer').load($(this).attr("href") + ' #flyer'); return false; }); 
        $("#fashion").mouseover(function(){ $('#flyer').load($(this).attr("href") + ' #flyer'); return false; }); 
        $("#self").mouseover(function(){ $('#flyer').load($(this).attr("href") + ' #flyer'); return false; }); 
        $("#nightlife").mouseover(function(){ $('#flyer').load($(this).attr("href") + ' #flyer'); return false; }); 
        $("#community").mouseover(function(){ $('#flyer').load($(this).attr("href") + ' #flyer'); return false; }); 
}); 
</script> 
+1  A: 

I like using a combination of jquery cycle (http://malsup.com/jquery/cycle/) for cycling content and jquery easing (http://gsgd.co.uk/sandbox/jquery/easing/) for some added animation effects to accomplish this

zincorp
I figured there was a "cycle" plugin but how do I go about implementing it? obviously, my jquery skills are limited.also, I forgot to mention that each flyer links to a different page.so while it's cycling through each flyer, the links should still be active.
P..
I guess I should have made clearer that i need to cycle through DIVs and not just images. apologies.
P..
A: 

OK. figured it out after reading the cycle plugin docs.thanks

P..
No problem. Please click the Checkbox beneath the down arrow to mark my response as the answer. =) Happy cycling.
zincorp
not the place to put comments, use the add comment link
Naeem Sarfraz
+2  A: 

Another way would be to use the setInterval function like so...

$(document).ready(function() { 
    var sourceElements = $("#art,#fashion,#self,#nightlife,#community");
    var pointer = 0;
    setInterval(function() {
        $('#flyer').load($(sourceElements[pointer++]).attr("href") + ' #flyer');
        if (!sourceElements[pointer]) pointer = 0;
    , 5000}); 
}); 
Naeem Sarfraz
very nice soulution :]
Adam Kiss