文字与图片互相切换js效果

<!DOCTYPE html>
<html>
<head>
<style>
a.blockA{display:block;width:200px;height:20px;overflow:hidden;white-space: nowrap;position: relative;}
a.blockA div{display:block;width:100%;height:100%;background-color:white;position: absolute;top:0px;left:0px;}
a.blockA img.bizLogo{width:10%;height:100%;}
a.blockA img.bizTel{width:89%;height:100%;}
</style>
</head>
<body>
<script src="http://icon.chinahrd.net/js/common.js"></script>
<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>


<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>

<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>
<script>
(function() {
    var taner, prer;
    var setTran = function(per, obj) {
        if (_.isIe) {
            obj.style.filter = 'alpha(opacity=' + per + ')';
        } else {
            obj.style.opacity = per / 100;
        }
    };
    var clear = function() {        
        clearInterval(taner);
    }
    _.each(_('&test'), function(_this) {
        _this.onmouseover = function () {
            clear();
            var per = 100;
            var obj = _.lastHtml(this);
            prer && setTran(100, prer);
            prer = obj;
            setTran(per, obj);
            taner = setInterval(function(){
                if (per-- < 0) {
                    clear();
                    return;
                } else {
                    setTran(per, obj);
                }
            }, 10);
        }

        _this.onmouseout = function () {
            clear();
            var per = 0;
            var obj = _.lastHtml(this);
            setTran(per, obj);
            taner = setInterval(function(){
                if (per++ > 100) {
                    clear();
                    return;
                } else {
                    setTran(per, obj);
                }
            }, 10);
        }
    });
})();
</script>
</body>
</html>

 

效果是透明成0显示图片,移开恢复不透明

 

文字与图片互相切换js效果 - qidizi - qidizi 的博客文字与图片互相切换js效果 - qidizi - qidizi 的博客

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值