Search code examples
jqueryjquery-tools

Can I attach a listener to the tabs in jQuery Tools?


I'd like to run a bit of code when a user clicks on one of the tabs in a jQuery Tools tabs implementation. Is this possible? I'm dubious, based on an initial look at the source, but ideas are welcome. I'm thinking about doing a slightly different version of the slide effect, one that makes my call in addition to the basic slide stuff. Thoughts?


Solution

  • Of course you can do it,

    $(function() {
        // setup ul.tabs to work as tabs for each div directly under div.panes
        $(".tabs li a").click(function() {
           alert($(this).html() + " clicked");
            return false;
        });
        $("ul.tabs").tabs("div.panes > div");
    });
    

    DEMO