首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >双亲悬停单元

双亲悬停单元
EN

Stack Overflow用户
提问于 2014-10-27 16:04:39
回答 1查看 31关注 0票数 0

我有以下循环:

代码语言:javascript
复制
<?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; ?>

以及以下jquery:

代码语言:javascript
复制
jQuery(function($) {
  $(document).ready(function() {      
    $(".module-nudge").hover(function(){
        $('.module-links').show();
    },function(){
        $('.module-links').hide();
    }); 
  });
});

当我在“. box n心思”元素上悬停时,它会显示“.box link”框。我遇到的问题是,它显示/隐藏了所有链接框,不管您在哪个父服务器上悬停。如何解决此问题,以便在悬停父元素时只显示相应的子元素?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-27 16:05:37

使用$(this).find()实现特定目标链接以获取module-nudge的后代module-links

代码语言:javascript
复制
$(".module-nudge").hover(function(){
    $(this).find('.module-links').show();
},function(){
    $(this).find('.module-links').hide();
}); 
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26591777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档