原创JQuery扩展函数 - 实现内容无缝滚动(兼容所有浏览器) 本帖最后由 Dean_L 于 2011-02-20 15:47:35 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 稍微修改了一下 如果内容不满则不复制第二个层 也不滚动因为权限不够 就先跟帖回复在这了/*****************************************************函数功能:扩展jQuery方法scrollStart()开始内容滚动。创建时间:2011年2月20日修改时间:2011年2月20日创建人员:李俊杰参数说明:speed指滚动速度,隐藏参数二指定间隔滚动速度*****************************************************/jQuery.fn.extend({ scrollStart : function (speed){ if(this.height() < this.children().first().height()){ this.append("<div></div>"); this.children().last().html(this.children().first().html()); this.scrollTop(0); function Marquee(Obj){ if(mySpeed == speed){ if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){ Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height()); }else{ Obj.scrollTop(parseInt(Obj.scrollTop()) + 1); } }else{ var i = 1; var myMar_ = window.setInterval(function(){ if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){ Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height()); }else{ Obj.scrollTop(parseInt(Obj.scrollTop()) + 1); i < Obj.height() ? i++ : clearInterval(myMar_); } }, speed); } } var mySpeed = arguments[1]||speed; var e = this; var myMar = window.setInterval(function(){Marquee(e);}, mySpeed); this.live("mouseover", function(){ clearInterval(myMar); }); this.live("mouseout", function(){ myMar = window.setInterval(function(){Marquee(e);}, mySpeed); }); } }}) 间隔式滚动的高度 = 外部包裹的DIV的高度如果出现意外 有可能是你外部包裹的DIV设置了内间隔 学习.还没经验.不会写jquery扩展 第二个间隔无缝滚动。有点不大明白。那修改后的是滚动div上面的js吧。但是不滚 如果出现意外 有可能是你外部包裹的DIV设置了内间隔 学习.还没经验.不会写jquery扩展 scrollStart : function (speed){ this.append(" <div> </div>"); this.children().last().html(this.children().first().html()); this.scrollTop(0); function Marquee(Obj){ if(mySpeed == speed){ if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){ Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height()); }else{ Obj.scrollTop(parseInt(Obj.scrollTop()) + 1); } }else{ var i = 1; var myMar_ = window.setInterval(function(){ if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){ Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height()); }else{ Obj.scrollTop(parseInt(Obj.scrollTop()) + 1); i < Obj.height() ? i++ : clearInterval(myMar_); } }, speed); } } var mySpeed = arguments[1]||speed; var e = this; var myMar = window.setInterval(function(){Marquee(e);}, mySpeed); this.live("mouseover", function(){ clearInterval(myMar); }); this.live("mouseout", function(){ myMar = window.setInterval(function(){Marquee(e);}, mySpeed); }); } where is the demo online ? jQuery.fn.extend({test:function(){ $(this).click(function(){ alert($(this).val());})}}) IE 和 火狐 兼容的问题 关于iframe的!急!!! 菜鸟起飞,老鸟来帮忙!!! js进度条 请大家帮我检查一个控制层的显示与隐藏的问题 高分求一个鼠标效果 javascript可以实现类似php的一些功能吗? 求助:鼠标放在单元格里的文字链接上时如何改变单元格背景图,离开时又恢复原来背景图 请大家保持良好的编程风格! javascript怎么使一个页面的值返回到另一个页面? 怎样替换用户输入字符串中的非法字符?在线等。。。。马上给分! xhEditor编辑器,如何响应focus事件 javascript中怎么换行和空格?
因为权限不够 就先跟帖回复在这了/*****************************************************
函数功能:扩展jQuery方法scrollStart()开始内容滚动。
创建时间:2011年2月20日
修改时间:2011年2月20日
创建人员:李俊杰
参数说明:speed指滚动速度,隐藏参数二指定间隔滚动速度
*****************************************************/
jQuery.fn.extend({
scrollStart : function (speed){
if(this.height() < this.children().first().height()){
this.append("<div></div>");
this.children().last().html(this.children().first().html());
this.scrollTop(0);
function Marquee(Obj){
if(mySpeed == speed){
if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){
Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height());
}else{
Obj.scrollTop(parseInt(Obj.scrollTop()) + 1);
}
}else{
var i = 1;
var myMar_ = window.setInterval(function(){
if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){
Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height());
}else{
Obj.scrollTop(parseInt(Obj.scrollTop()) + 1);
i < Obj.height() ? i++ : clearInterval(myMar_);
}
}, speed);
}
}
var mySpeed = arguments[1]||speed;
var e = this;
var myMar = window.setInterval(function(){Marquee(e);}, mySpeed);
this.live("mouseover", function(){
clearInterval(myMar);
});
this.live("mouseout", function(){
myMar = window.setInterval(function(){Marquee(e);}, mySpeed);
});
}
}
})
间隔式滚动的高度 = 外部包裹的DIV的高度
如果出现意外 有可能是你外部包裹的DIV设置了内间隔
this.append(" <div> </div>");
this.children().last().html(this.children().first().html());
this.scrollTop(0);
function Marquee(Obj){
if(mySpeed == speed){
if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){
Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height());
}else{
Obj.scrollTop(parseInt(Obj.scrollTop()) + 1);
}
}else{
var i = 1;
var myMar_ = window.setInterval(function(){
if(Obj.scrollTop() >= Obj.children().first().height() * 2 - Obj.height()){
Obj.scrollTop(Obj.scrollTop() - Obj.children().first().height());
}else{
Obj.scrollTop(parseInt(Obj.scrollTop()) + 1);
i < Obj.height() ? i++ : clearInterval(myMar_);
}
}, speed);
}
}
var mySpeed = arguments[1]||speed;
var e = this;
var myMar = window.setInterval(function(){Marquee(e);}, mySpeed); this.live("mouseover", function(){
clearInterval(myMar);
}); this.live("mouseout", function(){
myMar = window.setInterval(function(){Marquee(e);}, mySpeed);
});
}
test:function(){
$(this).click(function(){
alert($(this).val());
})
}})