dpnfjx755573 2016-01-25 07:20
浏览 122
已采纳

Jquery .hover显示位于foreach循环内的li标签中的所有箭头glyphicons

I'm a bit confused on how to properly insert my .hover() function inside my foreach li tags. cause when ever I hover my cursor on the assigned class all of the tags displays the glyphicon content.

here is my code.

jQuery(function() {

  jQuery(".side-nav").hover(function() {

    jQuery('.hover-arrow-right').show();

  });

});
<nav class="side-nav">
  <ul>
    <?php foreach($posts as $p): ?>
    <a href="<?php echo get_permalink($p->ID);?>">
      <li>
        <?php echo $p->post_title; ?><span class="hover-arrow-right"><i class="fa fa-chevron-right"></i></span>
      </li>
    </a>
    <?php endforeach; ?>
  </ul>
</nav>

the proper output is the glyphicon must only show when the cursor is placed on a li respectively.

sorry for my bad english.

thank you. hope anyone can help me in my problem.

</div>
  • 写回答

1条回答 默认 最新

  • doulao7998636570 2016-01-25 07:26
    关注

    you should do hover on the li

    jQuery(function() {
    
      jQuery(".side-nav ul a > li").hover(function() {
    
        jQuery(this).find('.hover-arrow-right').show();
    
     });
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器