0

要素のループ内の各要素に非表示のコンテンツを表示する jquery 関数があります。これは完全に機能しますが、問題は、新しい要素をループに追加すると機能しなくなることです。実際には一部の要素で機能し、他の要素では機能しません (奇妙な動作)。

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

  $(".see_all").click(function(){

  if ($(this).next().css('display') == 'none'){
  $(this).next().show();

  }
  else

  if($(this).next().is(':visible')){
  $(this).next().hide();
  }

  });
  })
  </script>

HTML コード

   <div class="center_container">
   <%for users in @user%>
   <div class="see_all">

   <span style="color:#808080;cursor:pointer">See All Reviews(<%=@beep_count=           (@beep.opposes.count +  @beep.neutrals.count + @beep.supports.count)%>)</span>

   </div>

   <div style="display:none;" class="hidden">

    No reviews available 

    </div>
   <%end%>

   </div>

私はこれでそれを解決しようとしました

   $("body").on("click", ".see_all", function() { 
   if ($(this).next().css('display') ==   'none')
    { 
    $(this).next().show(); 
    } 
    else 
    if($(this).next().is(':visible'))
    {                    
    $(this).next().hide(); 
    } 
    });

しかし、うまくいきませんでした。新しいjqueryソリューションで間違いを犯しています:(

助けてください

4

1 に答える 1

0

解決済み....jqueryファイルに互換性の問題があることがわかりました

于 2012-08-24T11:00:31.400 に答える