这是我的javascript代码:
$(".tab_content").hide(); //Hide all content
$("ul.tab_menu li:first").addClass("selected").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tab_menu li a").click(function() {
$("ul.tab_menu li a").removeClass("selected"); //Remove any "active" class
$(this).addClass("selected"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
参见:http://jsfiddle.net/MonicaPonciano/rs75z/
我在 iframe 中打开的 html 页面(其中包含带有 jquery 的脚本标记)中使用它,但链接不起作用,看起来像这样:
有人知道是什么原因造成的吗? 谢谢
最佳答案
我忘了把代码放在JS $(document).ready(function() { ... })
关于javascript - jQuery 选项卡容器 + Iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19725650/