锚点链接向下滚动到" Woocommerce评论标签"工作不正常。
<div class="woocommerce-product-rating">
<?php echo wc_get_rating_html( $average, $rating_count ); ?>
<?php if ( comments_open() ) : ?><a href="#tab-reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf( _n( '%s customer review', '%s customer reviews', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?>)</a><?php endif ?>
</div>
我已检查链接是否显示正确的锚点,即 Link to Review Tab
答案 0 :(得分:1)
这是因为评论div是隐藏的。如果您先点击评论标签,然后点击链接就可以了。
我认为您需要链接到评论标签,其中包含ID&#34; tab-title-reviews&#34;
<div class="woocommerce-product-rating">
<?php echo wc_get_rating_html( $average, $rating_count ); ?>
<?php if ( comments_open() ) : ?><a href="#tab-title-reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf( _n( '%s customer review', '%s customer reviews', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?>)</a><?php endif ?>
</div>
<script>
jQuery('.woocommerce-review-link').click(function(){
jQuery('#tab-title-reviews a').trigger('click');
});
</script>