dongzuo7166 2014-10-27 16:04
浏览 12
已采纳

父母的悬停元素

I have the following loop:

<?php if( have_rows('modules') ):
    $counter = 0;
    while ( have_rows('modules') ) : the_row(); ?>
        <div class="col span_4_of_12 <?php if($counter == 0) { ?>first<?php } ?>">      
            <div class="module-nudge">
                <span class="home-module <?php if($counter == 2) { ?>module-last<?php } ?>" style="background-image:url('<?php the_sub_field('icon'); ?>');">
                    <?php the_sub_field('text'); ?>
                </span>
                <?php if( have_rows('link') ): ?>
                    <span class="module-links">
                    <?php while ( have_rows('link') ) : the_row(); ?>
                        <a class="module-inner-link" href="<?php echo the_sub_field('link'); ?>"><?php echo the_sub_field('text'); ?></a>
                    <?php endwhile; ?>
                    </span>
                <?php endif; ?>                                     
            </div>
        </div>
        <?php $counter++;
    endwhile;
endif; ?>

And the following jquery:

jQuery(function($) {
  $(document).ready(function() {      
    $(".module-nudge").hover(function(){
        $('.module-links').show();
    },function(){
        $('.module-links').hide();
    }); 
  });
});

At the moment when I hover over the '.module-nudge' element it shows the '.module-links' box. The problem I have is that it's showing/hiding all the link boxes no matter which parent you hover. How can I fix this so only the corresponding child element shows when hovering the parent?

  • 写回答

1条回答 默认 最新

  • doujia1988 2014-10-27 16:05
    关注

    Target specific link using $(this).find() to get the descendent module-links of module-nudge

    $(".module-nudge").hover(function(){
        $(this).find('.module-links').show();
    },function(){
        $(this).find('.module-links').hide();
    }); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么