【发布时间】:2011-07-06 06:27:00
【问题描述】:
我有一个功能可以切换隐藏的 div 并且可以很好地使用它。不幸的是,“品牌”部分刚刚更改为“品牌”。代码由你们中的一位天才慷慨地改进和动态编写,并使用锚的内容名称来选择要显示/隐藏的 div。不幸的是,我需要(空间)品牌。没有bueno!
想法?谢谢!
附言如果您将 THE 从“show_brand”锚中取出,此功能将起作用。
HTML:
<div id="nav">
<div id="nav_left">
<a class="home" id="show_brand" title="BRAND">THE BRAND</a><br />
<a class="home" id="show_campaigns" title="CAMPAIGNS">CAMPAIGNS</a><br />
<a href="collection/" title="COLLECTION">COLLECTION</a><br />
<a class="home" id="show_inquiries" title="INQUIRIES">INQUIRIES</a>
</div>
<div id="campaigns">
<a href="campaigns/neo_balletto/" title="NEO BALLETTO">NEO BALLETTO</a><br />
<a href="campaigns/poetic_deco/" title="POETIC DECO">POETIC DECO</a>
</div>
</div>
<div class="current" id="brand">
<p>content</p>
</div>
<div id="inquiries">
<p>content</p>
</div>
Javascript:
$('#brand, #campaigns, #inquiries').hide();
$('.home').click(function() {
var id = $(this).html().toLowerCase();
var $content = $('#' + id + ':not(:visible)');
if ($('.current').length === 0) {
showContent($content)
}
else {
$('.current').fadeOut(600, function() {
showContent($content)
});
}
$('.home').css('text-decoration', 'none');
$(this).css('text-decoration', 'underline');
});
function showContent(content) {
content.fadeIn(600);
$('.current').removeClass('current');
content.addClass('current');
}
$('.close').click(function() {
$('.current').fadeOut(600);
});
【问题讨论】:
标签: jquery dynamic html toggle anchor