i think the best solution is to add an get attribute, in this case we don’t need javascript like this:
your single.php :
<div id="product-information">
<div id="tabs" class="htabs">
<a href="https://wordpress.stackexchange.com/questions/115110/<?php the_permalink(); ?>&tab=description" class="<?php echo !isset($_GET['tab']) || ($_GET['tab'] == 'description') ? 'selected':''; ?>">Description</a>
<a href="<?php the_permalink(); ?>&tab=comment" class="<?php echo isset($_GET['tab']) && ($_GET['tab'] == 'comment') ? 'selected':''; ?>">Comments</a>
<a href="<?php the_permalink(); ?>&tab=review" class="<?php echo isset($_GET['tab']) && ($_GET['tab'] == 'review') ? 'selected':''; ?>">Reviews</a>
</div>
<div id="tab-description" class="tab-content" style="display: <?php echo !isset($_GET['tab']) || ($_GET['tab'] == 'description') ? 'block;':'none;'; ?>">
<?php the_content(); ?>
</div>
<div id="tab-comment" class="tab-content" style="display: <?php echo isset($_GET['tab']) && ($_GET['tab'] == 'comment') ? 'block;':'none;'; ?>">
<?php if ( comments_open() || true): ?>
<?php comments_template( '', true ); ?>
<?php endif ?>
</div>
<div id="tab-review" class="tab-content" style="display: <?php echo isset($_GET['tab']) && ($_GET['tab'] == 'review') ? 'block;':'none;'; ?>;">
<h1>REVIEW</h1>
</div>
</div>
and in your function.php add this:
if ( ! function_exists( 'redirect_after_comment' ) ) {
function redirect_after_comment($location)
{
return get_permalink().'&tab=comment';
}
}
add_filter('comment_post_redirect', 'redirect_after_comment');