2013-03-26 43 views
1

我想把Pinterest的小部件放到我的网站上使用jQuery的标签,但它不显示任何东西。但是,当我把它放在标签之外时,它就起作用了。Pinterest的小部件与jQuery的标签冲突

我用这jQuery代码:

<script="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 

<script type="text/javascript"> 
$(document).ready(function() { 

    //Default Action 
    $(".tab_content").hide(); //Hide all content 
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab 
    $(".tab_content:first").show(); //Show first tab content 

    //On Click Event 
    $("ul.tabs li").click(function() { 
     $("ul.tabs li").removeClass("active"); //Remove any "active" class 
     $(this).addClass("active"); //Add "active" class to selected tab 
     $(".tab_content").hide(); //Hide all tab content 
     var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
     $(activeTab).fadeIn(); //Fade in the active content 
     return false; 
    }); 
}); 
</script> 

这对于Pinterest的(第二行是正如所指示的身体标记以上):

<a data-pin-do="embedUser" href="http://pinterest.com/thisismycyprus/"></a> 
<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script> 

这是标签代码

<ul class="tabs"> 
    <li><a href="#tab1">Tab 1</a></li> 
    <li><a href="#tab2">Tab 2</a></li> 
</ul> 
<div class="tab_container"> 
    <div id="tab1" class="tab_content"><h2>Tab 1</h2><p>Content </p></div> 
    <div id="tab2" class="tab_content"><h2>Tab 2</h2><p><a data-pin-do="embedUser" href="http://pinterest.com/thisismycyprus/"></a></p></div> 
</div> 
+0

你可以包括你的标签的标记呢? – couzzi 2013-03-27 04:09:30

+0

添加了标签代码 – user2212572 2013-03-27 06:33:51

回答

1

您已添加脚本$(window).load(function(){ });检查this fiddle

//<![CDATA[ 
$(window).load(function(){ 
//Default Action 
    $(".tab_content").hide(); //Hide all content 
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab 
    $(".tab_content:first").show(); //Show first tab content 

    //On Click Event 
    $("ul.tabs li").click(function() { 
     $("ul.tabs li").removeClass("active"); //Remove any "active" class 
     $(this).addClass("active"); //Add "active" class to selected tab 
     $(".tab_content").hide(); //Hide all tab content 
     var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
     $(activeTab).fadeIn(); //Fade in the active content 
     return false; 
    }); 
});//]]> 
+0

加载时有一个小延迟,但它的工作原理! – user2212572 2013-03-27 07:00:55

0

我的答案是关于Pinterest的/ JQuery的(不是jQuery的选项卡)

我曾在一个幻灯片使用Pinterest的饲料窗口小部件(http://business.pinterest.com/widget-builder/#do_embed_pin),我得到了同样的错误:当DIV容器在页面加载时为display:none;,Pinterest内容为空。

我用visibility:hidden;,而不是在我的div容器,初始化我的幻灯片(这开始前等待4秒),设置display:none;visibility:visible;,然后我可以使用jQuery show();/hide();