qq_31788907
2016-05-10 10:02
采纳率: 69.2%
浏览 1.1k
已采纳

把这段jQuery改成js代码

图片说明
这个是用jQuery的,

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • 已采纳
     <style>
        #ulMQ{width:500px}
        #ulMQ li a,#ulMQ li{overflow:hidden;zoom:1;clear:both;display:block}
    </style>
    <ul id="ulMQ">
        <li>
            <a href="#">
                <div><div id="span" style="float:left">¥</div></div>
                <div style="float:right;margin-right:20px;margin-top:-3px">按法律就饿哦发奇偶vcmaofjgeogjeomvfammafeofe</div>
            </a>
        </li>
        <li>
            <a href="#">
                <div><div id="span" style="float:left">¥</div></div>
                <div style="float:right;margin-right:20px;margin-top:-3px">按法律就饿哦发奇偶vcmaofjgeogjeomvfammafeofe</div>
            </a>
        </li>
    </ul>
    <script>
        if (typeof HTMLElement != 'undefined' && !HTMLElement.prototype.contains) HTMLElement.prototype.contains = function (o) { try { do { if (o == this) return true; } while (o = o.parentNode) } catch (e) { } return false}
        var ulMQ = document.getElementById('ulMQ');
        var as = ulMQ.getElementsByTagName('a');
        for (var i = 0; i < as.length; i++) {
            as[i].onmouseover = function (e) {
                e = e || window.event;
                var target = e.srcElement || e.target;
    
                var div = this.getElementsByTagName('div');
                div = div[div.length - 1];
                if (!/<marquee/i.test(div.innerHTML)) div.innerHTML = '<marquee scrollAmout=1 direction=left width="150px">' + div.innerHTML + '</marquee>';
            }
            as[i].onmouseout = function (e) {
                e = e || window.event;
                var target = e.toElement || e.relatedTarget;
                if (this.contains(target)) return;
    
                var div = this.getElementsByTagName('div');
                div = div[div.length - 1];
                div.innerHTML = div.innerHTML.replace(/<[^>]+>/g,'');
            }
        }
    </script>
    
    点赞 打赏 评论

相关推荐 更多相似问题