zoukankan      html  css  js  c++  java
  • 一段滚动文字的js (jQuery)

     function startmarqueeOneSMS() {
                        var t;
                        var to;
                        var ishover = false;
                        var waitone = 3000;
                        var speed = 30;
                        var currentI = 0;
                        var stop_margintop = {};
                        var o = document.getElementById("demo2");
                        var maxI = jQuery("div", o).length;
                        var tempmargintop = 0;
                        jQuery("div", o).each(function(index) {
                            tempmargintop += jQuery(this).outerHeight();
                            stop_margintop[index] = tempmargintop;
                        });
    
                        //复制一份避免出现空白
                        o.innerHTML += o.innerHTML;
                        o.style.marginTop = "0px";
    
                        function start() {
                            clearInterval(t);
                            clearTimeout(to);
                            t = setInterval(scrolling, speed);
                            //document.getElementById("kw").value = new Date().getSeconds();
                        }
                        o.onmouseover = function() {
                            clearInterval(t);
                            clearTimeout(to);
                        }
                        o.onmouseout = function() {
                            start();
                        }
                        function scrolling() {
                            var margintop = parseInt(o.style.marginTop);
                            if (stop_margintop[currentI] == Math.abs(margintop)) {
                                clearInterval(t);
                                currentI++;
                                if (currentI == maxI) {
                                    o.style.marginTop = "0px";
                                    currentI = 0;
                                }
                                to=setTimeout(start, waitone);
                            }
                            else {
                                //向上滚动1PX
                                o.style.marginTop = parseInt(margintop) - 1 + "px";
                            }
                        }
                        start();
                    }
                    startmarqueeOneSMS();
                });

    在原来的一直滚动稍微改了一下,每滚动一条之后停一会儿。

  • 相关阅读:
    Python str转化成数字
    MySQL之CONCAT()的用法
    MySQL之LIMIT用法
    MySQL中LOCATE用法
    设计模式-模版方法
    设计模式-单例模式
    设计模式-桥接模式
    UML图标含义及记忆方法
    redis-分布式锁-消除竞争条件
    redis-分布式锁-刷新信号量
  • 原文地址:https://www.cnblogs.com/jgjgjg23/p/3958846.html
Copyright © 2011-2022 走看看