triggering a jquery ui tab from a link?

Posted on 2009-04-28
Last Modified: 2013-11-11
Hi There,

I'm trying to trigger a jquery tab click from a link outside the container. Can someone help me with this code please?

<!doctype html>

<html lang="en">


	<title>jQuery UI Tabs - Default functionality</title>


	<link type="text/css" href="/themes/base/ui.all.css" rel="stylesheet" />

	<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>

	<script type="text/javascript" src="ui/ui.core.js"></script>

	<script type="text/javascript" src="ui/ui.tabs.js"></script>

 <style type="text/css" media="screen">



	<script type="text/javascript">

	$(function() {



$(document).ready(function() {

    $("div#tbanavigation ul.tabNavigation li a").click(function(event) {

        var targetTab = $(this).get(0).id;


        $("div#thetabclass div#tabs ul li a").eq(targetTab).toggle();


        return false;







    <div id="tbanavigation">

            <ul class="tabNavigation">

		        <li><a id="t1" href="#bottom">Nunc tincidunt</a></li>

		        <li><a id="t2" href="#bottom">Proin dolor</a></li>

		        <li><a id="t3" href="#bottom">Aenean lacinia</a></li>





<div id="thetabclass">

        <div id="tabs">


		        <li><a href="#tabs-1">Nunc tincidunt</a></li>

		        <li><a href="#tabs-2">Proin dolor</a></li>

		        <li><a href="#tabs-3">Aenean lacinia</a></li>


	        <div id="tabs-1">

		        <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>



	        <div id="tabs-2">

		        <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>



	        <div id="tabs-3">

		        <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>




</div><!-- End demo -->



Open in new window

Question by:MrAgile
    1 Comment
    LVL 16

    Accepted Solution

    You can select a tab by calling


    where index is the 0-based index of the tab you want to select.

    Also, for future reference, there are a bunch of options available for tabs, and they can all be seen here:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now