Jquery控制文字横向移动

这篇博客介绍了如何利用Jquery实现文字横向滚动的两种方法,并提供了详细的JS代码示例,包括设置速度、响应鼠标事件等。通过调用`.textScroll()`函数,可以将指定的元素设置为滚动状态。
摘要由CSDN通过智能技术生成

首先html页面代码定义

 <div class="navbar-inner" id="s" style="width:600px; position:relative; white-space:nowrap; overflow:hidden; height:60px;">
<div id="noticeList" style="position:absolute; top:0; height:20px;"> <span>截止目前:共提交问卷${alltotal}份,盐田${mt3total}份,蛇口${mt4total}份,赤湾${mt1total}份,大铲${mt2total}份。实时更新中~ </span><div>
 </div>


Js代码

方法一:

$.fn.textScroll= function (){
     var speed=60,flag= null ,tt,that=$( this ),child=that.children();
     var p_w=that.width(), w=child.width();
     child.css({left:p_w});
     var t=(w+p_w)/speed * 1000;
     function play(m){
         var tm= m==undefined ? t : m;
         child.animate({left:-w},tm, "linear" , function (){            
             $( this ).css( "left" ,p_w);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值