【问题标题】:Getting error: Uncaught TypeError: Object .thumbnail has no method 'hover'出现错误:未捕获的类型错误:对象 .thumbnail 没有方法“悬停”
【发布时间】:2012-04-14 22:55:43
【问题描述】:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        ('.thumbnail').hover(
            function () {
            $('.hovImage').css('display', 'block');
        }, function () {
            $('.hovImage').css('display', 'none');
        });
    });
</script>

上面出现错误“Uncaught TypeError: Object .thumbnail has no method 'hover'”。我无法弄清楚错误来自哪里。请帮忙!

【问题讨论】:

  • 你能发布相关的html部分吗?没有它很难说

标签: jquery


【解决方案1】:

哦,你的问题,这是一个语法错误,你错过了$

||
VV
$('.thumbnail').hover()

顺便说一句,你可以这样做:

$('.thumbnail').hover(
    function () {
    $('.hovImage').show();
}, function () {
    $('.hovImage').hide();
});

【讨论】:

    【解决方案2】:

    您在这里忘记了一个$('.thumbnail').hover(

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.thumbnail').hover(
                function () {
                $('.hovImage').css('display', 'block');
            }, function () {
                $('.hovImage').css('display', 'none');
            });
        });
    </script>
    

    【讨论】:

      猜你喜欢
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      • 2013-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多