我通常尝试做的是,检测我们来自 Trustpilot Widget 的产品是否有 0 条评论,如果是,则显示来自 Trustpilot 的另一个小部件,它显示我们服务的评论数量。
现在,当在页面上找到一个名为“tp-stars--0”的 div 类时,我一直试图隐藏小部件。
这是我到目前为止得到的
$('.trustpilot-widget' ).ready(function() {
if($('.tp-widget-stars').find('.tp-stars.tp-stars--0').length) {
$('#tp-widget-wrapper').removeClass('visible');
}
});
<div id="tp-widget-wrapper" class="tp-widget-wrapper visible">
<div id="wrapper-company-stars" class="wrapper-company-stars">
<!-- Stars -->
<div id="tp-widget-stars" class="tp-widget-stars">
<div class="">
<div class="tp-stars tp-stars--0">
<div style="position: relative; height: 0; width: 100%;
padding: 0; padding-bottom: 18.326693227091635%;">
</div>
</div>
</div>
</div>
<div class="tp-widget-readmore" id="numberOfReviews"><strong>No
reviews</strong>
</div>
</div>
</div>