JS 设置某个div中a标签有href就去掉 :after 遮罩层

 html:

<div class="fl">
    <a>
        <span class="jwHover">
            <img src="img/jiwu07.png" >
        </span>
    </a>
</div>

 css:

.jwHover {
    position: relative;
}
.jwHover:after {
    position: absolute;
    top: 0;
    left: 0;
    content: "";
    background-color: #444;
    opacity: 0.8;
    z-index: 1;
    width: 100%;
    height: 100%;
}

 js:

$(document).ready(function () { 
    $('.mainBody a').each(function(index, el) {
        if ($(this)[0].href !== "") {
            // console.log($(this))
            $(this).children('span').removeClass('jwHover')
        }
    });
})

 

posted @ 2019-01-24 16:24  格鲁特baby  阅读(235)  评论(0编辑  收藏  举报