码迷,mamicode.com
首页 > Web开发 > 详细

js随笔

时间:2016-05-13 09:19:45      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

nav横幅滚动

html代码

1 <div class=‘box‘>
2     <label class=‘tips‘><span id=‘tip‘>我是我是我是我是顶上的横幅</span></label>
3 </div>

js代码

 1  function scrollTip(){
 2     var flag = 0;
 3     setInterval(function () {
 4       var tip = $(‘#tip‘);
 5       var box = $(‘.box‘).eq(0);
 6       var marginLeft = (tip.css(‘marginLeft‘)).replace(‘px‘,‘‘);
 7       if((Math.abs(marginLeft)+(box.width()))==(tip.width()+30)){
 8         flag = 1;
 9       } else if(Math.abs(marginLeft) == 0) {
10         flag = 0;
11       }
12       if(flag === 0){
13         tip.css(‘marginLeft‘,(marginLeft-1)+‘px‘);
14       } else {
15         tip.css(‘marginLeft‘,(parseInt(marginLeft)+1)+‘px‘);
16       }
17     },50);
18   }
19   scrollTip();

 

js随笔

标签:

原文地址:http://www.cnblogs.com/margarita/p/5485485.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!