jQuery 选项卡。选项卡内的链接到选项卡
更新
大家好!
链接工作正常,但现在我面临另一个问题。当我单击选项卡中的链接并再次单击“菜单”选项卡时,选项卡看起来很糟糕。请参阅下面的工作示例链接和代码。
Rgds
muttmagandi
http://www.vallatravet.se/thetabs/
$(document).ready(function(){
$(".fadeOut").fadeTo(0, 0.5);
$("#forklara").bind("click", function(e)
{
$("div:hidden:#one").fadeIn("slow");
});
$(".Rehabilitering").bind("click", function() {
var $tabs= $("#container-1").tabs();
$tabs.tabs('select', 3); // switch to third tab
$("div:hidden:#one").fadeIn("slow");
return false;
});
$(".SO").bind("click", function() {
var $tabs= $("#container-1").tabs();
$tabs.tabs('select', 3); // switch to third tab
$("div:hidden:#two").fadeIn("slow");
return false;
});
});
</script>
<div id="container-1">
<ul>
<li><a href="#fragment-1"><span>one</span></a></li>
<li><a href="#fragment-2"><span>two</span></a></li>
<li><a href="#fragment-3"><span>three</span></a></li>
<li><a href="#fragment-4"><span id="forklara">four</span></a></li>
</ul>
<div id="fragment-1">
<div class="cat-1">
<li><a href="#Rehabilitering" class="Rehabilitering">Rehabilitering</a></li>
<li><a href="#SO" class="SO">Second opinion</a></li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li class="fadeOut">Sjukgymnastik, naprapat & kiropraktor</li>
<li class="fadeOut">Psykologi</li>
<li class="fadeOut">Personstöd</li>
</div>
</div>
<div id="fragment-2">
<div class="cat-1">
<li><a href="#tolast" class="tolast">Rehabilitering</a></li>
<li>Second opinion</li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li>Sjukgymnastik, naprapat & kiropraktor</li>
<li class="fadeOut">Psykologi</li>
<li class="fadeOut">Personstöd</li>
</div>
</div>
<div id="fragment-3">
<div class="cat-1">
<li><a href="#tolast" class="tolast">Rehabilitering</a></li>
<li>Second opinion</li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li>Sjukgymnastik, naprapat & kiropraktor</li>
<li>Psykologi</li>
<li>Personstöd</li>
</div>
</div>
<div id="fragment-4">
<div id="one" style="padding:25px 0px 0px 20px; display:none;"><b>Rehabilitering</b><br />
The event handler is passed an event object that you can use to prevent default behaviour. To stop both default action and event bubbling, your handler has to return false.
</div>
<div id="two" style="padding:25px 0px 0px 20px; display:none;"><b>Second opinion</b><br />
Ytterligare bedömning av annan läkare vid allvarlig sjukdom eller svårt medicinskt ställningstagande.
</div>
</div>
</div>
Update
Hi guys!
Got the linking working but now im facing another problem. When i've clicked the link within the tab and clicks on the "Menu"-tab again, the tabs look like shit. See working example link and code below.
Rgds
muttmagandi
http://www.vallatravet.se/thetabs/
$(document).ready(function(){
$(".fadeOut").fadeTo(0, 0.5);
$("#forklara").bind("click", function(e)
{
$("div:hidden:#one").fadeIn("slow");
});
$(".Rehabilitering").bind("click", function() {
var $tabs= $("#container-1").tabs();
$tabs.tabs('select', 3); // switch to third tab
$("div:hidden:#one").fadeIn("slow");
return false;
});
$(".SO").bind("click", function() {
var $tabs= $("#container-1").tabs();
$tabs.tabs('select', 3); // switch to third tab
$("div:hidden:#two").fadeIn("slow");
return false;
});
});
</script>
<div id="container-1">
<ul>
<li><a href="#fragment-1"><span>one</span></a></li>
<li><a href="#fragment-2"><span>two</span></a></li>
<li><a href="#fragment-3"><span>three</span></a></li>
<li><a href="#fragment-4"><span id="forklara">four</span></a></li>
</ul>
<div id="fragment-1">
<div class="cat-1">
<li><a href="#Rehabilitering" class="Rehabilitering">Rehabilitering</a></li>
<li><a href="#SO" class="SO">Second opinion</a></li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li class="fadeOut">Sjukgymnastik, naprapat & kiropraktor</li>
<li class="fadeOut">Psykologi</li>
<li class="fadeOut">Personstöd</li>
</div>
</div>
<div id="fragment-2">
<div class="cat-1">
<li><a href="#tolast" class="tolast">Rehabilitering</a></li>
<li>Second opinion</li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li>Sjukgymnastik, naprapat & kiropraktor</li>
<li class="fadeOut">Psykologi</li>
<li class="fadeOut">Personstöd</li>
</div>
</div>
<div id="fragment-3">
<div class="cat-1">
<li><a href="#tolast" class="tolast">Rehabilitering</a></li>
<li>Second opinion</li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li>Sjukgymnastik, naprapat & kiropraktor</li>
<li>Psykologi</li>
<li>Personstöd</li>
</div>
</div>
<div id="fragment-4">
<div id="one" style="padding:25px 0px 0px 20px; display:none;"><b>Rehabilitering</b><br />
The event handler is passed an event object that you can use to prevent default behaviour. To stop both default action and event bubbling, your handler has to return false.
</div>
<div id="two" style="padding:25px 0px 0px 20px; display:none;"><b>Second opinion</b><br />
Ytterligare bedömning av annan läkare vid allvarlig sjukdom eller svårt medicinskt ställningstagande.
</div>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你的问题只是 JavaScript 中缺少大括号和括号,因为相同的代码在添加这两件事后工作正常 - http://jsbin.com/eriba/2。
应该是...
I think your problem is just a missing brace and parenthesis in your JavaScript because the same code works fine with those two things added - http://jsbin.com/eriba/2 .
Should be...
不,你的问题是
在这里:
您已经选择了类名“tolast”的元素,其中 onclick 指向第三个选项卡。
在这里您可以看到有两个该元素的类设置为“tolast”,
我确信当您单击任一锚点时,第三个选项卡将打开(我可以看到它是错误的)。
我建议这样:
然后:
no, your problem is that
in here:
you have selected the elements with classname 'tolast' which the onclick points to the third tab.
here you can see you have two of that element that has the class set to 'tolast'
I'm sure when you click either of that anchors the third tab will open (Which I can see it's wrong).
I suggest something like this:
then: