/    Sign up×
Community /Pin to ProfileBookmark

selecting tabs, this is probably really easy..

I have a problem. I have a tabs script and I have the code to link to a specific tab from outside the DIV tag. I need to link to all 3 tabs, though, not just 1 like I have now. What do I need to change in the Javascript part so that I can link to 3 tabs not just 1?

HTML Code:

[CODE]
<div id=”test_tabs” class=”ui-tabs”>
<ul>
<li><a href=”#tab1″>Tab 1</a></li>
<li><a href=”#tab2″>Tab 2</a></li>
<li><a href=”#tab3″>Tab 3</a></li>
</ul>
<div id=”tab1″>Content 1</div>

<div id=”tab2″>Content 2</div>
<div id=”tab3″>Content 3</div>
</div>
<br/>
<hr/>
<div id=”show_1″>Outside link to Tab 1</div>
<div id=”show_2″>Outside link to Tab 2</div>
<div id=”show_3″>Outside link to Tab 3</div>
[/CODE]

Javascript Code:

[CODE]
<script>
$(function() {
$(‘#test_tabs’).tabs();

$(‘#show_3’).click(function(event) {
$(‘#test_tabs’).tabs(‘select’, 2);
}).css({
color : ‘blue’,
cursor : ‘pointer’
});
});
</script>
[/CODE]

I tried changing it to:

[CODE]
<script>
$(function() {
$(‘#test_tabs’).tabs();

$(‘#show_1’).click(function(event) {
$(‘#test_tabs’).tabs(‘select’, 0);

$(‘#show_2’).click(function(event) {
$(‘#test_tabs’).tabs(‘select’, 1);

$(‘#show_3’).click(function(event) {
$(‘#test_tabs’).tabs(‘select’, 2);
}).css({
color : ‘blue’,
cursor : ‘pointer’
});
});
</script>
[/CODE]

But that didn’t work ?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @shannont spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...