jquery toggle()似乎不适用于chrome / safari

时间:2011-07-20 10:11:40

标签: jquery toggle

我在chrome / safari中使用toggle()时遇到了困难。我玩noconflict()没有任何运气。在chrome和safari中,第一个食谱翻译在德语下弹出。现在其他两个食谱就像我预期的那样工作。我怎么能解决这个问题的铬和野生动物园?

//$.noConflict();

 $(window).load(function() { 

  $('#recipes').orbit({
    timer: false,  
    bullets: true,
    captions: true,     
    afterSlideChange: textSlides
  });

    $("a.lang").click(function (e) {
        var contentSpan = $(this).parent().attr('class');
        e.preventDefault();
        $("span."+contentSpan).toggle();
    });
  });

  function textSlides() {   
    var theId = "#d" + $(this).attr('id');
    $(theId).toggle().siblings().hide();
  }

我的html是

<div id="recipes-text">
<div id="dr1">
  <span class="language_content_dr1" >
    <h3>WORTEL CHUTNEY</h3>
    <p><strong>ingrediënten</strong><br />
    asdfasd german</p>
    <a class="lang" href="#">English</a>
    </span>    
  <span  class="language_content_dr1" style="display:none;">
  <h3>CARROT CHUTNEY</h3>
    <p>recipe<br />
    english </p>
    <a class="lang" id="de" href="#de_tri">german</a>
    </span>

</div>
<div id="dr2" style="display:none;">
    <span class="language_content_dr2">
    section 222 jawohl<br />

    <a class="lang" href="#">English</a><br />
    </span>
    <span class="language_content_dr2" style="display:none;">

    section 222 english <br />

    <a class="lang" id="de" href="#de_tri">german</a>
    </span>
</div>
<div id="dr3" style="display:none;">
    <span class="language_content_dr3">
    ection 333 jawohl<br />

    <a class="lang" href="#">English</a>
    </span>

    <span class="language_content_dr3" style="display:none;">
    section 333 english<br />
    <h3>CARROT CHUTNEY</h3>
    <p>recipe<br />
    english
    </p>
<a class="lang" id="de" href="#de_tri">German</a>
    </span>
</div>
</div>

1 个答案:

答案 0 :(得分:3)

将您的跨度更改为div。

<span class="language_content_dr1" >


<div class="language_content_dr1" >

这一行:

$("a.lang").click(function (e) {
    e.preventDefault();
    var contentSpan = $(this).parent().attr('class');
    $("div."+contentSpan).toggle();
});