首页 新闻 会员 周边 捐助

有两个广告条通栏。想实现效果当鼠标划过某个广告时该广告条放大。现在问题是无论划过哪个都是下面的放大!

0
悬赏园豆:50 [已解决问题] 解决于 2012-08-27 17:00

<html>
<head>
<script type="text/javascript">

var ads_toggle = [2465, 2468];

var ads_autoshow = [];
var init_ads = function() {
if (ads_toggle.length > 0){
for (var i = 0; i < ads_toggle.length; i++){
var el = document.getElementById('ad_pos_' + ads_toggle[i]);
if (el) {
var oDiv_mouseout = el.getElementsByTagName("div")[1];

var oDiv_mouseover = el.getElementsByTagName("div")[0];

oDiv_mouseout.onmouseover = function(e){
oDiv_mouseout.style.display = 'none';
oDiv_mouseover.style.display = '';
}
oDiv_mouseover.onmouseover = function(e){
oDiv_mouseout.style.display = 'none';
oDiv_mouseover.style.display = '';
}
oDiv_mouseout.onmouseout = function(e){
oDiv_mouseout.style.display = '';
oDiv_mouseover.style.display = 'none';
}
oDiv_mouseover.onmouseout = function(e){
oDiv_mouseout.style.display = '';
oDiv_mouseover.style.display = 'none';
}
}
}
}
}

if (document.all) {
window.attachEvent("onload", function(){init_ads();});
} else {
window.addEventListener("load", function(){init_ads();}, false);
}
</script>

</head>
<body>

<div id="ad_pos_2465">
<div style="display:none;">
放大的内容!!!!!!!!!!!!
</div>

<div>
原来的内容
</div>
</div>


<div id="ad_pos_2468">
<div style="display: none;">
放大的内容!!!!!!!!!!!!
</div>
<div>
原来的内容
</div>
</div>


</body>
</html>

子之芷茗的主页 子之芷茗 | 初学一级 | 园豆:157
提问于:2012-08-03 16:10
< >
分享
最佳答案
3
<html>
<head>
<script type="text/javascript">
    var ads_toggle = [2465, 2468];
    var ads_autoshow = [];
    var init_ads = function () {
        if (ads_toggle.length > 0) {
            for (var i = 0; i < 2; i++) {
            (function(i){
                var el = document.getElementById('ad_pos_' + ads_toggle[i]);
                if (el) {
                
                    var oDiv_mouseout = el.getElementsByTagName("div")[1];
                    var oDiv_mouseover = el.getElementsByTagName("div")[0];
                    oDiv_mouseout.onmouseover = function (e) {
                        oDiv_mouseout.style.display = 'none';
                        oDiv_mouseover.style.display = '';
                    }
                    oDiv_mouseover.onmouseover = function (e) {
                        oDiv_mouseout.style.display = 'none';
                        oDiv_mouseover.style.display = '';
                    }
                    oDiv_mouseout.onmouseout = function (e) {
                        oDiv_mouseout.style.display = '';
                        oDiv_mouseover.style.display = 'none';
                    }
                    oDiv_mouseover.onmouseout = function (e) {
                        oDiv_mouseout.style.display = '';
                        oDiv_mouseover.style.display = 'none';
                    }
                }
                })(i)
            }
        }
    }
    if (document.all) {
        window.attachEvent("onload", function () { init_ads(); });
    } else {
        window.addEventListener("load", function () { init_ads(); }, false);
    }
</script>
</head>
<body>
<div id="ad_pos_2465">
<div style="display:none;">
放大的内容1!!!!!!!!!!!!
</div>
<div>
原来的内容
</div>
</div>
<hr/>
<div id="ad_pos_2468">
<div style="display: none;">
放大的内容2!!!!!!!!!!!!
</div>
<div>
原来的内容
</div>
</div>

</body>
</html>
收获园豆:50
林J | 菜鸟二级 |园豆:202 | 2012-08-03 17:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册