dongyangzhi0687
2014-11-21 19:58
浏览 34
已采纳

我无法将鼠标悬停事件分配给我的jquery函数

I have a menu that when I click on a bottom,the menu items will be appear.but I need to change this code when I put my mouse on it the menu items be appear (not by click). here is my html code of menu and it's jQuery:

<div class="menu_block">
    <nav id="bt-menu" class="bt-menu">
        <a href="#" class="bt-menu-trigger"><span>Menu</span></a>
        <ul>
            <li class="current bt-icon"><a href="index.php">Home</a></li>
            <li class="bt-icon"><a href="about.php">About</a></li>
            <li class="bt-icon"><a href="products.php">Products</a></li>
            <li class="bt-icon"><a href="projects.php">Projects</a></li>
            <li class="bt-icon"><a href="trading.php">Trading</a></li>
            <li class="bt-icon"><a href="Contacts.php">Contacts</a></li>
        </ul>
    </nav>
    <div class="clear"></div>
</div>

and this is my jquery code:

<script>
    $(document).ready(function(){
        $(".bt-menu-trigger").toggle(
            function(){
                $('.bt-menu').addClass('bt-menu-open');
            },
            function(){
                $('.bt-menu').removeClass('bt-menu-open');
            }
        );
        $('.responsive').on('click', '.close', function(){
            $('.close').remove();
            bgColor = $('.active .card-front').css('background-color');
            $('.responsive').removeClass(effect);
            $('.all-content').hide();
            $('.content li').removeClass('active').show().css({ 
                'border-bottom':'1px solid #2c2c2c',
                'border-left':'1px solid #2c2c2c' 
            });
            $('.card-front, .card-back').show();
            $('.content').css('background-color',bgColor);
        });
</script>
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dousao9569 2014-11-25 06:30
    已采纳

    Try to use .hover(): http://api.jquery.com/hover/

    $('.responsive').hover(function() {
         $('.close').remove();
         bgColor = $('.active .card-front').css('background-color');
    
         ......
    
    });
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题