3

我对我的 jquery 知识有点(更像是非常)生疏。出于某种原因,当绿色框悬停在上面时,我无法弄清楚我在这里缺少什么来使蓝色框消失。

剧本:

 $(document).ready(function() {
    $(".hover-text").hover({
    $(".hover-hide").animate({
        opacity: 0.4,
    }, 500);
    });​

的HTML:

 <div class="hover-hide">
    <div class="hover-text">
        BLAH
    </div>
    </div>

的CSS:

 .hover-hide{
    width:200px;
    height:200px;
    background-color:blue;
    padding:30px;
    }
    .hover-text{
    color:white;
    background-color:green;
    padding:10px;
    width:auto;
    margin-top:20px;
    }​​

非常感谢!:)

4

2 回答 2

5

的第一个参数.hover是回调函数,应该是$('.hover-text').hover(function(){. 在这里拉小提琴。

于 2012-12-03T20:49:13.050 回答
1

您错过了通话function后的内容。.hover此外,您在结尾处缺少右括号和括号.ready();

应该:

$(document).ready(function() {     

    $(".hover-text").hover( function() {     
        $(".hover-hide").animate({ opacity: 0.4, }, 500);     
    });

});

这是一个小提琴:http: //jsfiddle.net/TMZhJ/

于 2012-12-03T20:50:40.913 回答