繁体   English   中英

jQuery在Wordpress中悬停:在隐藏的div中淡出,而淡出“默认”值

[英]jQuery hover in Wordpress: fading in a hidden div while fading out the “default” one

我在将jQuery的悬停功能与Wordpress循环一起使用时遇到问题。 每次我悬停一张图像(有6张)时,它们都会消失,而不仅仅是单张图像。 请帮忙。

这是我的代码:

<?php query_posts('showposts=6&cat=-4'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); if ( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>

<li class="show1">

<?php $thumb = get_post_meta($post->ID, 'thumb', true); ?>

<a href="#" title="Permanent Link to <?php the_title_attribute(); ?>" class="show"><?php echo$thumb; ?></a>

<div class="hide">

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    <?php the_excerpt(); ?>

    <a class="view_project" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">View Project »</a>
</div>
</li>

我的JavaScript是

<script type="text/javascript">
$(function() {
$('li.show1').children('.hide').hide();

$('li.show1').hover(function() {
    $(this).children('a.show').fadeOut('slow')
        .end().children('.hide').fadeIn('slow');
}, function() {
    $(this).children('a.show').fadeIn('slow')
        .end().children('.hide').fadeOut('slow');
});
});
</script>

多谢你们。

替换$('a.show')$(this).children('a.show') -这将限制你淡出到内部锚链接li这是盘旋。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM