定位嵌套<a> element and removing its href attribute using JavaScript/jQuery

时间:2016-01-26 05:54:38

标签: javascript jquery html

I need a little help with removing the href element of the below 'a' element:

<div class="carousel__tape-item js-product">
    <div class="sale-content__cell">
        <a href="www.website.com"></a>
    </div>
</div>

This is my attempt but it doesn't work:

var a = $(".carousel__tape-item .sale-content__cell");
a.find("a").removeAttr("href");

Any ideas?

1 个答案:

答案 0 :(得分:1)

您想对jquery

使用多选择器语法

$(document).ready(function() { $('.carousel__tape-item.js-product').find('a').removeAttr('href'); });

查看实际操作:https://jsfiddle.net/ahc1uLdj/