jQuery控制台错误:$(this).效果不是函数

jQuery console error: $(this).effect is not a function

本文关键字:函数 this 错误 控制台 jQuery      更新时间:2023-09-26

我已经盯着我的代码好几个小时了,现在试图弄清楚为什么这个看似简单的jQuery游戏不起作用:

<!DOCTYPE HTML>
<html>
    <head>
        <title>title</title>
        <meta charset="UTF-8">
        <meta name="keywords" content="test">
        <meta name="description" content="test">
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <p class='box' id='title'>&quot;test&quot;</p>
        <div class='gallery'>
            <p class='tNail' id='one'>
            <p class='tNail' id='two'>
            <p class='tNail' id='three'>
            <div class='clear'></div>
            <p class='tNail' id='four'>
            <p class='tNail' id='five'>
            <p class='tNail' id='six'>
            <div class='clear'></div>
        </div>
        <div class='clear'></div>
        <p class='footer'>test 2011 <a href='#'>test</a></p>
    </body>
    <script type="text/javascript" src="jquery.js"></script>
    <script>
        $(document).ready(function()
        {
            $(".tNail").click(function()
            {
                $(this).effect("scale", {percent:200, direction:'both'}, 1000);
            });
        });
    </script>
</html>

我试过使用noConflict(),但无济于事。如果有人能指点一下,我将不胜感激。

谢谢。

啊,再看一遍,我认为错误信息可能是"$(this).effect不是一个函数"(这与${this}相当不同)。你还没有加载jQuery UI,这是effect方法被定义的地方。

包含jQuery UI库并重试