【发布时间】:2021-05-23 04:05:46
【问题描述】:
我需要将 'wsqmylogin' 添加到现有的 a href 类中,
以便该类可以显示 class="wsqmylogin add-request-quote-button"。
我尝试了以下代码,但它删除了现有属性(添加请求引用按钮)。
请告诉我如何在不删除现有值的情况下插入值?
现有代码(由插件创建):
<div class="yith-ywraq-add-to-quote add-to-quote-1389">
<div class="yith-ywraq-add-button show" style="display:block" data-product_id="1389">
<a href="#" class="add-request-quote-button button" >Add to quote</a>
</div>
</div>
我试过了:
jQuery(".yith-ywraq-add-button a").attr({class: "wsqmylogin"});
jQuery(".yith-ywraq-add-button a").prop({class: "wsqmylogin"});
谢谢你。
【问题讨论】:
标签: jquery wordpress class insert