2014-03-01 2 views
1

내 블로그에서 링크를 클릭하고 소셜 공유 메뉴를 표시해야합니다. 그러나, 내가 이것을 넣었을 때 : span.link를 클릭 할 때마다, 이것을 넣을 때 :다중 및 동적 show(); ul의

$(document).ready(function() { 
    $("ul.social").hide(); 

    $("span.link").click(function(){ 
    $("ul.social").show("slow"); 
    }); 
}); 

언제나 나는 ul.social을 보여줍니다. 나는 단지 지시 대상을 보여줄 필요가있다.

그래서
  <section class="post-home-content"> 
      <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?> | <?php bloginfo('name') ?> | <?php bloginfo('description') ?>"><?php the_title(); ?></a></h2> 
      <p><?php the_field('sub_titulo'); ?></p> 

      <span class="link">Share</span> 

      <time class="post-time" datetime="<?php the_time('d-m-Y'); ?> <?php the_time('G:i'); ?>"><?php the_time('d/m/Y'); ?></time> 
      </section> 

      <ul class="social"> 
      <li><img src="<?php bloginfo('template_url'); ?>/img/in.png" alt="" width="24" /></li> 
      <li><img src="<?php bloginfo('template_url'); ?>/img/gp.png" alt="" width="24" /></li> 
      <li><img src="<?php bloginfo('template_url'); ?>/img/fb.png" alt="" width="24" /></li> 
      <li><img src="<?php bloginfo('template_url'); ?>/img/tw.png" alt="" width="24" /></li> 
      </ul> 

일 :

는 루프?

답변

0

사용 eq() 방법은 인덱스를 사용하여 jQuery를 개체를 선택하고, 각 span 태그 완료

$(document).ready(function() { 
    $("ul.social").hide(); 
    $("span.link").each(function(i) { 
     $(this).click(function() { 
      $("ul.social").eq(i).show("slow"); 
     }); 
    }); 
}); 
+0

를 얻을 수 each() 방법을 사용합니다! 감사! : D –

+0

@FilipeFernandes : 기꺼이 도와주세요. –