This article describes the left and right moving focus graph effect implemented by jQuery. Share it for your reference, as follows:
jquery part:
$(function () { var _speed = 1000; var _len = 0; var _size = 150; var _direction = 'left'; function mar(){ if(_direction == 'left'){ if(_len >= 450){ _direction = 'right'; }else{ $(".flow ul").animate({"margin-left":"-=" + _size + "px"}); _len += _size; } }else{ if(_len <= 0){ _direction = 'left'; }else{ $(".flow ul").animate({"margin-left":"+=" + _size + "px"}); _len -= _size; } } } var _go = setInterval(mar,_speed); $("#pic_left").click(function (){ _direction = 'left'; }); $("#pic_right").click(function (){ _direction = 'right'; }); $(".flow li").mouseover(function (){ clearInterval(_go); }).mouseout(function (){ _go = setInterval(mar,_speed); }); });
html part
<div class="salebox"> <A class="left" >left</A> <DIV class="pcont" > <DIV class="ScrCont"> <div class="flowbox" style="width:150px; height:60px; overflow:hidden;float:left;"> <div class="flow" style="width:150px;height:60px;"> <ul > <li><img src="__PUBLIC__/images/demo/" mce_src="__PUBLIC__/images/demo/" width="150px" height="60px"></li> <li><img src="__PUBLIC__/images/demo/" mce_src="__PUBLIC__/images/demo/" width="150px" height="60px"></li> <li><img src="__PUBLIC__/images/demo/" mce_src="__PUBLIC__/images/demo/" width="150px" height="60px"></li> <li><img src="__PUBLIC__/images/demo/" mce_src="__PUBLIC__/images/demo/" width="150px" height="60px"></li> </ul> </div> </div> </DIV> </DIV> <A class="right" >right</A> </div>
For more information about jQuery special effects, readers who are interested in view the topic of this site:Summary of jQuery animation and special effects usage"and"Summary of common classic effects of jQuery》
I hope this article will be helpful to everyone's jQuery programming.