下载了wordpress的主题,自己加了点jquery来实现菜单的显示隐藏,但是有点小问题,就是鼠标在菜单上移动,菜单就会不断的显示隐藏,感觉就像菜单之间存在不是菜单的部分,导致不断的引发hover事件,
jquery的代码:
<script type="text/javascript"> 
$(document).ready(function(){
 $(".me").hide();
$(".widget").hover(function(){
    $(".me").slideToggle();
  });
});
</script>具体问题的效果可以去www.jianglijie.net看,求高手指教

解决方案 »

  1.   

    楼主发你的html代码看看,而且hover函数是需要2个参数的,1,移入时执行的函数,2,移出时执行的函数
      

  2.   

    $(".widget").hover(
      function(){
         $(".me").show();
      },  function(){
         $(".me").hide();
      }
    );
      

  3.   

    你这种焦点有点不太好控制的,如果你的标题是水平排列的话不会出现这种情况
    $(document).ready(function () {
                $(".me").hide();
                $(".widget").each(function () {
                    $(this).hover(function () {
                        $(".me", this).show();
                    },
                function () {
                    $(".me", this).hide();
                });
                });
            });
      

  4.   

    $(".widget").hover(
      function(){
         $(".me").show();
      },
      function(){
         $(".me").hide();
      }
    );这是正确的写法,如果还有问题 肯定是你的html布局有问题
      

  5.   

    整个文件是
    <script type="text/javascript" src="http://www.jianglijie.net/wp-content/themes/zbench/jquery.js"></script><script type="text/javascript"> 
    $(document).ready(function(){
     $(".me").hide();
      $(".widget").hover(
      function(){
      $(".me").show();
      },
      function(){
      $(".me").hide();
      }
    );});
    </script><div id="sidebar-border">
    <div id="rss_border">
    <div class="rss_border">
    <div id="rss_wrap">
    <div class="rss_wrap">
    <?php global $zbench_options; $rss_text='';
    if($zbench_options['twitter_url'] == '' && $zbench_options['facebook_url'] == '' && $zbench_options['googleplus_url'] == '') $rss_text='rss_text'; ?>
    <a class="rss <?php echo $rss_text;?>" href="<?php if($zbench_options['rss_url'] != '') { echo($zbench_options['rss_url']); } else { bloginfo('rss2_url'); } ?>" rel="book" title="<?php _e('RSS Feed', 'zbench'); ?>"><?php _e('RSS Feed', 'zbench'); ?></a>
    <?php if($zbench_options['twitter_url'] != '') : ?>
    <a class="twitter" href="<?php echo($zbench_options['twitter_url']); ?>" rel="author" title="<?php _e('Follow me on twitter.', 'zbench'); ?>"><?php _e('Follow me on twitter.', 'zbench'); ?></a>
    <?php endif; ?>
    <?php if($zbench_options['facebook_url'] != '') : ?>
    <a class="facebook" href="<?php echo($zbench_options['facebook_url']); ?>" rel="author" title="<?php _e('Facebook', 'zbench'); ?>"><?php _e('Facebook', 'zbench'); ?></a>
    <?php endif; ?>
    <?php if($zbench_options['googleplus_url'] != '') : ?>
    <a class="googleplus" href="<?php echo($zbench_options['googleplus_url']); ?>" rel="me" title="<?php _e('Google+', 'zbench'); ?>"><?php _e('Google+', 'zbench'); ?></a>
    <?php endif; ?>
    <?php if($zbench_options['social_network_1_name'] != '' && $zbench_options['social_network_1_img'] != '' && $zbench_options['social_network_1_url'] != '') : ?>
    <a style="background:url(<?php echo $zbench_options['social_network_1_img']; ?>) no-repeat 0 0;" href="<?php echo($zbench_options['social_network_1_url']); ?>" title="<?php echo($zbench_options['social_network_1_name']); ?>" rel="book"><?php echo($zbench_options['social_network_1_name']); ?></a>
    <?php endif; ?>
    <?php if($zbench_options['social_network_2_name'] != '' && $zbench_options['social_network_2_img'] != '' && $zbench_options['social_network_2_url'] != '') : ?>
    <a style="background:url(<?php echo $zbench_options['social_network_2_img']; ?>) no-repeat 0 0;" href="<?php echo($zbench_options['social_network_2_url']); ?>" title="<?php echo($zbench_options['social_network_2_name']); ?>" rel="book"><?php echo($zbench_options['social_network_2_name']); ?></a>
    <?php endif; ?>
    </div>
    </div>
    </div>
    </div>
    <div id="sidebar"><?php if ( !dynamic_sidebar('primary-widget-area') ) : ?><?php if ( is_singular() ) { ?>
    <div class="widget">
    <h3><?php _e('Recent Posts', 'zbench'); ?></h3>
    <div class="me">
    <ul>
    <?php
    $myposts = get_posts('numberposts=5&offset=0&category=0');
    foreach($myposts as $post) : setup_postdata($post);
    ?>
    <li><span><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span></li>
    <?php endforeach; ?>
    </ul>
    </div>
    </div>
    <?php } else { ?>
    <div class="widget">
    <h3><?php _e('Random Posts', 'zbench'); ?></h3>
    <div class="me">
    <ul>
    <?php
    $rand_posts = get_posts('numberposts=5&orderby=rand');
    foreach( $rand_posts as $post ) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    </div>
    </div>
    <?php } ?>
    <div class="widget">
    <h3><?php _e('Search by Tags!', 'zbench'); ?></h3>
    <div class="me">
    <?php wp_tag_cloud('smallest=9&largest=18'); ?>
    </div>
    </div>
    <div class="widget">
    <h3><?php _e('Archives', 'zbench'); ?></h3>
    <div class="me">
    <ul>
    <?php wp_get_archives( 'type=monthly' ); ?>
    </ul>
    </div>
    </div>
    <div class="widget">
    <h3><?php _e('Links', 'zbench'); ?></h3>
    <div class="me">
    <ul>
    <?php wp_list_books('title_li=&categorize=0&orderby=id'); ?>
    </ul>
    </div>
    </div>
    <div class="widget">
    <h3><?php _e('Meta', 'zbench'); ?></h3>
    <div class="me">
    <ul>
    <?php wp_register(); ?>
    <li><?php wp_loginout(); ?></li>
    <?php wp_meta(); ?>
    </ul>
    </div>
    </div><?php endif; ?><?php if ( is_singular() ) { if ( is_active_sidebar('singular-widget-area') ) dynamic_sidebar('singular-widget-area'); } ?>
    <?php if (!is_singular()) { if ( is_active_sidebar('not-singular-widget-area') ) dynamic_sidebar('not-singular-widget-area'); } ?>
    <?php if ( is_active_sidebar('footer-widget-area') ) dynamic_sidebar('footer-widget-area'); ?> </div><!-- end: #sidebar -->
    </div><!-- end: #sidebar-border -->
    效果还是没有正常的状态,应该怎么办啊,对于jquery现学现用
      

  6.   

    干脆吧  $(".widget").hover 换成 $("#sidebar").hover 吧。。