jquery 上下滚动广告
(function($){
$.fn.extend({
rollList:function(option){
option=$.extend({
direction:"up",
step:1,
time:23
},option);
var step_coe,scroll_coe,score_coe;
if(option.direction=="up")
{
step_coe=1;
scroll_coe=1;
score_coe=1;
}else
{
step_coe=-1;
scroll_coe=-1;
score_coe=0;
}
return this.each(function(){
var $this=$(this);
var _this=this;
var itemHeight;
var temp=$("<DIV> </DIV>");
$this.css("overflow","hidden").children()
.appendTo(temp);
$this.append(temp.clone(true)).append(temp);
itemHeight=$this.children();
itemHeight=itemHeight.eq(1).offset().top-itemHeight.eq(0).offset().top;
while($this.children(":last").offset().top-$this.offset().top<=$this.height())
$this.append(temp.clone(true));
var roll;
this.scrollTop=itemHeight*(1-score_coe);
roll=function (){
temp=setInterval(function(){
if(_this.scrollTop*scroll_coe>=itemHeight*score_coe)
{
_this.scrollTop=(_this.scrollTop-itemHeight)*scroll_coe;
}
_this.scrollTop+=option.step*step_coe;
},option.time);
}
$this.hover(function(){
clearInterval(temp);
},function(){
roll();
});
roll();
});
}
})
}(jQuery));
$(elem).rollList();
相关推荐
-
JS实现单行文字不间断向上滚动的方法
本文实例讲述了JS实现单行文字不间断向上滚动的方法.分享给大家供大家参考.具体分析如下: 前几天帮一个朋友写了一个单行文字不间断向上滚动的JS效果,现在分享给需要的weber.先看HTML和CSS代码: CSS: 复制代码 代码如下: .wrap{padding:10px;border:1px #ccc solid; width:500px;margin:20px auto;} .roll-wrap{height:130px;overflow:hidden;} HTML: 复制代码 代码如下:
-
一个JQuery写的点击上下滚动的小例子
功能需求: 1.滚动框内显示10条记录: 2.有向上和向下滚动按钮,每次点击按钮向上或向下滚动记录条数,不自动滚动: 3.记录条数不循环滚动,滚动到起点或终点则停止滚动. 下面介绍一个简单实现方法: 1.外层容器(div) overflow: hidden,内层列表(ul) 2.按钮点击事件触发一个修改列表的函数 3.应用animate实现动画效果 具体不再啰嗦,直接上代码 CSS设置 复制代码 代码如下: <style type="text/css"> ul, li {
-
Jquery数字上下滚动动态切换插件
Jq打造的数字滚动插件,数字变化时,动态滚动切换,效果非常好. 我们先来看示例: CSS .textC { position:absolute; width:500px; overflow:hidden; margin-top: 100px; line-height:30px; margin-left: 300px; height:30px; } .textC span { color: #13BEEC; font-size: 28px; font-weight: bold; font-fami
-
随鼠标上下滚动的jquery代码
复制代码 代码如下: //随鼠标上下滚动 $(window).bind('scroll resize',function(){ $('#sidebar').stop(true, true).animate({ 'top': $(document).scrollTop() + 'px' },500); }).scroll().resize();
-
如何使用jquery实现文字上下滚动效果
实现文字上下滚动是经常用到的js效果,这里介绍一种上下渐隐渐出的文字展现效果! <!DOCTYPE> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>文字滚动</title> <style type="text/css"> #sidebar{width:20
-
js实现的文字横向无间断滚动
我一开始想到的标签是<marquee>,因为它可以实现横向滚动.经理说它的起始位置从最右边出来的,能不能将它改成从中间出来,或者从最左边出来也行.查了相关资料,才知道<marquee>无法指定起始位置.后来在网上找到一段代码,它是用图片来实现的,我将图片改成文字之后,顺利地实现了我所想要的功能.代码如下: #gongao{width:1000px;height:30px;overflow:hidden;line-height:30px;font-size:13px;font-fam
-
jquery 实现上下滚动效果示例代码
复制代码 代码如下: <script type="text/javascript" src="script/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function() { var page = 1; var i = 1; var conheight = $('.con li').height(); var lilen =
-
js 上下文字滚动效果
js实现的文字向上滚动效果,适合文字公告等. test #textHeight{line-height:25px; height:25px; overflow:hidden; width:150px; font-size:12px; border:solid 1px #666;} function ScrollText(content){ this.Delay=10; this.Amount=1; this.Direction="up"; this.Timeout=1000; this
-
jquery文字上下滚动的实现方法
复制代码 代码如下: //上下滚动 var textRoll=function(){ $('#notice p:last').css({'height':'0px','opacity': '0'}).insertBefore('#notice p:first').animate({'height':'35px','opacity': '1'}, 'slow', function() { $(this).removeAttr('style');}); } $(function(){ //触发上下文
-
jquery 上下滚动广告
复制代码 代码如下: (function($){ $.fn.extend({ rollList:function(option){ option=$.extend({ direction:"up", step:1, time:23 },option); var step_coe,scroll_coe,score_coe; if(option.direction=="up") { step_coe=1; scroll_coe=1; score_coe=1; }else
-
jQuery网页右侧广告跟随滚动代码分享
两种方法都分享给大家,希望对大家的学习有所启发. 方法一: <script type="text/javascript">// <