2 qq 31788907 qq_31788907 于 2016.05.10 18:02 提问

把这段jQuery改成js代码

图片说明
这个是用jQuery的,

1个回答

showbo
showbo   Ds   Rxr 2016.05.10 21:21
已采纳
 <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>
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!