aaronegan
aaronegan

Reputation: 64

How to open product tab on click of link?

I'm trying to get a particular tab on a webpage to open when a link is clicked. Not only that, I need the page to scroll down to that area once it's clicked too (like an anchor tag).

Here's the page I'm working on:

http://www.lifestyleclotheslines.com.au/hills-portable-170-clothesline/

The link I'm working on is the blue '154 reviews' link next to the gold stars under the product title. When this is clicked, I need it to open the 'Reviews (140)' tab further below, and also scroll down to that area.

Here's what I currently have wrapped around the link:

<a onclick="ActiveProductTab('ProductReviews_Tab'); window.scrollTo(0,jQuery('#ProductReviews').offset().top); return false; ">154 reviews</a>

It's not working at all, nothing happens when I click.

Any ideas? Thanks!

Upvotes: 0

Views: 1105

Answers (2)

SlyBeaver
SlyBeaver

Reputation: 1312

You can use this code:

<a onclick="$('#ReviewsTabLink').click();
$('html, body').animate({
            scrollTop: $('#ReviewsTabLink').offset().top + 'px'
        }, 'fast'); ">154 reviews</a>

It work on your site. I tested now.

Upvotes: 2

Arun P Johny
Arun P Johny

Reputation: 388406

The review tab header has the id ReviewsTabLink, so you can manually trigger a click event(since I'm not seeing any plugin that is used for the tab - if you have used any plugin for the tab you can look at its documentation to see if there is an option to set the active tab like the active option in jQuery UI tabs)

jQuery('#ReviewsTabLink').click()

Upvotes: 0

Related Questions