jQuery.addClass不工作 [英] jQuery.addClass not working

查看:79
本文介绍了jQuery.addClass不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来有效,但它不工作。我想让huhdiv在菜单悬停时变得不透明。

This looks valid but it's not working. I'd like the 'huh' div to become opaque when the menu is hovered over. I tried this with fadein/out and it worked but just the once which was odd.

 <script type="text/javascript">
    $( function() {
        $('#menuNav').hover( function() {
            $('#huh').addClass('.opacity');
        }, function(){
            $('#huh').removeClass('.opacity');
        });
    });

</script>

.opacity {
    opacity: 0.3;
}


推荐答案

/ p>

Use it without dot:

 $(function(){

        $('#menuNav').hover(function(){

            $('#huh').addClass('opacity');
        }, function(){
            $('#huh').removeClass('opacity');
        });
    });

这篇关于jQuery.addClass不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆