javascript - How to pause the news slider on mouse hover and play on mouse out.? -
<body> <ul id="ticker"> <li> <p>innovation - power of 4s progress of auto industry stands on 4 basic pillars.</p> <p>the s pillars , not overstatement combination thr illed auto-indutry.</p> </li> <li> <p>innovation - power of 4s progress of auto industry stands on 4 basic pillars.</p> <p>the s pillars , not overstatement combination thr illed auto-indutry.</p> </li> <li> <p>innovation - power of 4s progress of auto industry stands on 4 basic pillars.</p> <p>the s pillars , not overstatement combination thr illed auto-indutry.</p> </li> </ul> <script> function tick(){ $('#ticker li:first').slideup( function () { $(this).appendto($('#ticker')).slidedown(); }); } setinterval(function(){ tick () }, 2000);
code simple news slider. how pause news slider on mouse hover , play on mouse out.?
assign setinterval variable, there's 1 interval object can reuse.
var interval_id = setinterval(...
on hover events, use clearinterval(interval_id) stop it, , reinstate on mouse leave/out.
Comments
Post a Comment