jquery代码产生未定义的错误 [英] jquery code produces not defined error

查看:89
本文介绍了jquery代码产生未定义的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解为什么下面的代码在firebug中给我这个错误

I cannot understand why the code below is giving me this error in firebug

$未定义

有人可以解释一下吗?

<script type="text/javascript" >
 $(document).ready(function(){
  setTimeout2(function(){
  $("#errormsg4").fadeOut("slow", function () {
  $("#errormsg4").remove();
      }); }, 5000);
 });
</script>

<div id="errormsg4">test</div>


推荐答案

如你所说$未定义意味着你有在使用脚本代码之前没有给出jquery脚本文件的引用。另外我认为你输错了setTimeout2,它本来是setTimeout.Try下面代码

As you said $ is not defined that means you have not given the reference of jquery script file before using your script code. Also I think you had mistyped setTimeout2,it would have been setTimeout.Try below code

<html>
<head>
    <title></title>    
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>    
</head>
<body>
    <div id="errormsg4">
        test</div>
</body>    
<script type="text/javascript">

    $(document).ready(function()
    {
        setTimeout(function()
        {
            $("#errormsg4").fadeOut("slow", function()
            {
                $("#errormsg4").remove();
            });
        }, 5000);
    });
</script>

</html>

这篇关于jquery代码产生未定义的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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