Search code examples
jquerytwitter-bootstraponclickjquery-tabs

how to call a function onclick (reference error)


I'm working with Twitter Bootstrap, I have a link which when clicked I want to open one of the accordian tabs (and scroll nice and smooth)

It works first time, if i open other tabs then try the link again i get a reference error saying 'openTab' is not defined.

Here's what I have so far:

HTML:

<a href='#reviews' class="star-ratingT" onclick="openTab()">Write a review</a>

jQuery:

$(function(openTab) {
$(".review-tab").trigger("click");
});

Solution

  • $(document).ready(function() {
        $(".stat-ratingT").click(function () { 
            $(".review-tab").trigger("click");
        });
    });