JavaScript未捕获的ReferenceError:未定义jQuery;未捕获的ReferenceError: $没有定义[duplicate]

时间:2022-11-06 15:08:18

This question already has an answer here:

这个问题已经有了答案:

This is my fiddle, http://jsfiddle.net/4vaxE/35/

这是我的小提琴,http://jsfiddle.net/4vaxE/35/。

It work fine in my fiddle.

它在我的小提琴里演奏得很好。

However, when I transfer it to dreamweaver, it can't work. And I found this two error in my coding.

但是,当我将它转移到dreamweaver时,它不能工作。我在编码中发现了这两个错误。

  1. Uncaught ReferenceError: jQuery is not defined
  2. 未捕获的ReferenceError:未定义jQuery
  3. uncaught referenceerror $ is not defined
  4. 未捕获的referenceerror $未定义。

I had read before the article related to this two error, and tried to solve according to the method provided, however, it still not working, how can I solve this?

我之前读过这两个错误的相关文章,并尝试按照提供的方法去解决,但是还是没有效果,我怎么解决呢?

Here is my full coding in dreamweaver

这是我在dreamweaver中的全部代码

<body>
    <div class="buttons" style="background-color: rgba(0,0,0,.8);">
    <a class="button" id="showdiv1">Div 1</a>
    <a class="button" id="showdiv2">Div 2</a>
    <a class="button" id="showdiv3">Div 3</a>
    <a class="button" id="showdiv4">Div 4</a>
    </div>

    <div id="div1">1</div>
    <div id="div2">2</div>
    <div id="div3">3</div>
    <div id="div4">4</div>
</div>
<script language="JavaScript" type="text/javascript" script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>

<script language="JavaScript" type="text/javascript">
var selectedEffect="explode";
var options = { percent: 100 };
$('#showdiv1').click(function () {
    $('div[id^=div]').hide();

    $('#div1').show( selectedEffect, options, 500, callback );
});
$('#showdiv2').click(function () {
    $('div[id^=div]').hide();
    $('#div2').show( selectedEffect, options, 500, callback );
});

$('#showdiv3').click(function () {
    $('div[id^=div]').hide();
    $('#div3').show( selectedEffect, options, 500, callback );
});

$('#showdiv4').click(function () {
    $('div[id^=div]').hide();
    $('#div4').show( selectedEffect, options, 500, callback );
});

function callback() {
      setTimeout(function() {
        $( "#effect:visible" ).removeAttr( "style" ).fadeOut();
      }, 1000 );
    };
</script>
</body>
</html>

CSS

CSS

<style type="text/css">

.button {
    cursor:pointer;
    display:inline-block;
    margin:10px;
    clip: rect(auto,auto,auto,auto);
}

#div1 {
    background:aqua;
    padding:20px;
    width:100px;
    text-align:center;
    display:none;
}
#div2 {
    background:blue;
    padding:20px;
    width:100px;
    text-align:center;
    display:none;
}
#div3 {
    background:orange;
    padding:20px;
    width:100px;
    text-align:center;
    display:none;
}

#div4 {
    background:green;
    padding:20px;
    width:100px;
    text-align:center;
    display:none;
}
a {
    color:aqua;
    -webkit-filter: grayscale(1.0);
}
a:hover {
    color:red;
    -webkit-filter: grayscale(0.0);
}
</style>

3 个解决方案

#1


34  

Cause you need to add jQuery library to your file:

因为你需要在你的文件中添加jQuery库:

jQuery UI is just an addon to jQuery which means that
first you need to include the jQuery library → and then the UI.

jQuery UI是一个jQuery插件,这意味着首先需要包括jQuery库→然后UI。

<script src="path/to/your/jquery.min.js"></script>
<script src="path/to/your/jquery.ui.min.js"></script>

#2


4  

You did not include jquery library. In jsfiddle its already there. Just include this line in your head section.

您没有包含jquery库。在jsfiddle已经有了。把这句话写在你的头部部分。

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">

#3


4  

You have an error in you script tag construction, this:

您在脚本标记构造中有一个错误,如下所示:

<script language="JavaScript" type="text/javascript" script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>

Should look like this:

应该是这样的:

<script language="JavaScript" type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>

You have a 'script' word lost in the middle of your script tag. Also you should remove the http:// to let the browser decide whether to use HTTP or HTTPS.

在脚本标签中间有一个“脚本”字丢失。还应该删除http://,让浏览器决定是使用HTTP还是HTTPS。

UPDATE

更新

But your main error is that you are including jQuery UI (ONLY) you must include jQuery first! jQuery UI and jQuery are used together, not in separate. jQuery UI depends on jQuery. You should put this line before jQuery UI:

但是您的主要错误是您要包含jQuery UI(仅),您必须首先包含jQuery !jQuery UI和jQuery一起使用,而不是单独使用。jQuery UI依赖于jQuery。你应该在jQuery UI前加上这一行:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>

#1


34  

Cause you need to add jQuery library to your file:

因为你需要在你的文件中添加jQuery库:

jQuery UI is just an addon to jQuery which means that
first you need to include the jQuery library → and then the UI.

jQuery UI是一个jQuery插件,这意味着首先需要包括jQuery库→然后UI。

<script src="path/to/your/jquery.min.js"></script>
<script src="path/to/your/jquery.ui.min.js"></script>

#2


4  

You did not include jquery library. In jsfiddle its already there. Just include this line in your head section.

您没有包含jquery库。在jsfiddle已经有了。把这句话写在你的头部部分。

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">

#3


4  

You have an error in you script tag construction, this:

您在脚本标记构造中有一个错误,如下所示:

<script language="JavaScript" type="text/javascript" script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>

Should look like this:

应该是这样的:

<script language="JavaScript" type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>

You have a 'script' word lost in the middle of your script tag. Also you should remove the http:// to let the browser decide whether to use HTTP or HTTPS.

在脚本标签中间有一个“脚本”字丢失。还应该删除http://,让浏览器决定是使用HTTP还是HTTPS。

UPDATE

更新

But your main error is that you are including jQuery UI (ONLY) you must include jQuery first! jQuery UI and jQuery are used together, not in separate. jQuery UI depends on jQuery. You should put this line before jQuery UI:

但是您的主要错误是您要包含jQuery UI(仅),您必须首先包含jQuery !jQuery UI和jQuery一起使用,而不是单独使用。jQuery UI依赖于jQuery。你应该在jQuery UI前加上这一行:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>