【问题标题】:jQuery Tab Containers + IframejQuery 选项卡容器 + Iframe
【发布时间】:2013-11-01 20:01:42
【问题描述】:

这是我的 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 的脚本标记)中使用它,但链接不起作用,看起来像这样:

有人知道是什么原因造成的吗? 谢谢

【问题讨论】:

  • 您的 jsFiddle 示例在这里看起来不错。
  • 控制台有错误吗?也许另一个脚本正在破坏这个。
  • 同意@MelanciaUK
  • 是的.. 这就是问题所在,当我在 iframe 中调用的 html 页面中使用它时,它不起作用。
  • 该死,这是一个愚蠢的错误!我忘了把我的代码放在 $ (function () {});对不起,伙计们..

标签: javascript jquery html css iframe


【解决方案1】:

我忘了把代码放在JS里面$(document).ready(function() { ... })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多