Jquery 当子div具有特定的类名时,隐藏div的类
我通常想做的是,检测Trustpilot小部件中的产品是否有0个评论,如果是,则显示Trustpilot中的另一个小部件,该小部件显示我们服务的评论数 现在,当在页面上找到一个名为“tp stars--0”的div类时,我一直试图隐藏这个小部件 这是我到目前为止得到的Jquery 当子div具有特定的类名时,隐藏div的类,jquery,shopify,trustpilot,Jquery,Shopify,Trustpilot,我通常想做的是,检测Trustpilot小部件中的产品是否有0个评论,如果是,则显示Trustpilot中的另一个小部件,该小部件显示我们服务的评论数 现在,当在页面上找到一个名为“tp stars--0”的div类时,我一直试图隐藏这个小部件 这是我到目前为止得到的 $('.trustpilot-widget' ).ready(function() { if($('.tp-widget-stars').find('.tp-stars.tp-stars--0'
$('.trustpilot-widget' ).ready(function() {
if($('.tp-widget-stars').find('.tp-stars.tp-stars--0').length) {
$('#tp-widget-wrapper').removeClass('visible');
}
});
没有
评论
从元素开始,找到父元素
$('.tp-stars--0').parent('#tp-widget-wrapper').removeClass('visible');
$('.tp-widget-stars').find('.tp-stars.tp-stars--0').each(function() {
if ($(this).length) {
$(this).closest('#tp-widget-wrapper').removeClass('visible');
}
});
从元素开始,找到父元素
$('.tp-stars--0').parent('#tp-widget-wrapper').removeClass('visible');
$('.tp-widget-stars').find('.tp-stars.tp-stars--0').each(function() {
if ($(this).length) {
$(this).closest('#tp-widget-wrapper').removeClass('visible');
}
});
尝试在元素上使用
每个
循环,并使用最近的
获取父元素
$('.tp-stars--0').parent('#tp-widget-wrapper').removeClass('visible');
$('.tp-widget-stars').find('.tp-stars.tp-stars--0').each(function() {
if ($(this).length) {
$(this).closest('#tp-widget-wrapper').removeClass('visible');
}
});
尝试在元素上使用
每个
循环,并使用最近的
获取父元素
$('.tp-stars--0').parent('#tp-widget-wrapper').removeClass('visible');
$('.tp-widget-stars').find('.tp-stars.tp-stars--0').each(function() {
if ($(this).length) {
$(this).closest('#tp-widget-wrapper').removeClass('visible');
}
});
.parent()
,否?.parent()
,否?