【发布时间】:2013-04-23 16:07:04
【问题描述】:
原始标签:请检查此 URL:http://basarhost.com/tab
添加新标签:请检查此 URL:http://basarhost.com/tab/mynewtab/
正如您在网站上看到的那样,第二个无法正常工作。
这是我的 javascript:
$(document).ready(function() {
/* Activate H5F */
$('ul#tabs li').click(function() {
/* If what we clicked is the actual link, we move make the changes */
if($(this).attr("class") == "inactiveTab") {
/* Swap classes on the clicked item */
$(this).addClass('activeTab').removeClass('inactiveTab');
/* Swap classes on the other LI */
$(this).siblings('.activeTab').removeClass('activeTab').addClass('inactiveTab');
/* Change the float of the previous element */
$(this).prev().css("float", "left");
/* We toggle the tabs */
$("div.toggleTab").slideToggle("fast", function() {
/* Once the animation is complete, focus the first field of the visible form */
$("div.toggleTab input:visible").first().focus();
});
}
});
});
你有什么建议吗?
【问题讨论】:
-
请在 jsfiddle 等可访问的站点中发布相关测试用例
-
这是因为
floatcss 属性。您应该根据您的目的设置所有选项卡的float属性,您只需将所有内容设置为float: left -
欢迎来到 Stack Overflow。这怎么不能正常工作?能不能说的具体点?
-
@John 正如您在示例中看到的那样,我有三个 div。我想在单击选项卡时显示关系 div。
-
@OrkunB 我很抱歉。我过快地阅读了审查队列中的帖子,我没有看到您在代码中放置的非常清晰的 cmets。请忽略我的评论,再次欢迎您。
标签: javascript jquery css tabs