javascript - jQuery open div on hover; automatic scroll through -


i have ul list several links in it, , each item linked own div. when user hovers on ul link, proper div box shown.

here html code:

<ul class="productlist">   <li><a href="#" id="link0" class="product-link">link 1</a></li>   <li><a href="#" id="link2" class="product-link">link 2</a></li>   <li><a href="#" id="link3" class="product-link">link 3</a></li> </ul>  <div class="panel-overview boxlink" id="boxlink0"> goes here 1 </div> <div class="panel-overview boxlink" id="boxlink1"> goes here 2 </div> <div class="panel-overview boxlink" id="boxlink2"> goes here 3 </div> 

and javascript makes work (not javascript expert, sorry):

<script> $(function() {     var $boxes = $('.boxlink');     $('.productlist .product-link').mouseover(function() {         $boxes.hide().filter('#box' + this.id).show();     });     }); </script> 

i wondering how can make boxes scrolled through automatically every 3 4 seconds. example, first div opened 3 seconds, second, third...

here the live site, since haven't described properly.

your description wasn't clear me, how interpereted after viewing website: cycle through links show nice images. happen automatically. but. if user wants navigate, cycle should stop

here code that.

$(document).ready(function () {   var $boxes = $('.boxlink');   var $links = $('.product-link');   var cycle = false;   var cycle_step = 0;    $('.productlist .product-link').mouseenter(function() {     boxactivate(this.id);     stopcycle();   });    $('.productlist .product-link').mouseleave(function() {     cycle = settimeout(function(){         startcycle();     }, 1000);   });    var boxactivate = function(id){     $boxes.hide().filter('#box' + id).show();   }   // cycle - when mouse not on links   var startcycle = function(){     cycle = setinterval(function(){         boxactivate($links.get(cycle_step).id);         cycle_step++;         if(cycle_step==$links.length) {             cycle_step=0;         }     }, 1000);   }   var stopcycle = function(){     clearinterval(cycle);   }    startcycle();  }); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -