在HTML中链接jQuery [英] linking jquery in html

查看:65
本文介绍了在HTML中链接jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法成功将jQuery链接到我的html.我已经使最简单的jQuery代码成为可能,所以我知道这是对的,并且我已经尝试了所有我能想到的-搜索没有帮助.

I can't manage to successfully link jQuery to my html. I have made the most simple jQuery code possible just so I know it's right, and I've tried everything I can think of - searching hasn't been helpful..

我的html(文件名:"test.html":

my html(file name: "test.html":

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
        <link rel="stylesheet" type="css/text" href="test.css"/>
        <script type="text/javascript" src="test.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    </head>
    <body>
        <div id="orange"></div>
    </body>
</html>

我的CSS(文件名:"test.css"):

my CSS(file name: "test.css"):

#orange {
    height: 100px;
    width: 100px;
    background-color: orange;
    border-radius: 5px;
    border: 3px solid black;
    margin-left: 100px;
    margin-top: 100px;
    display: none;
}

我的JS(文件名:"test.js"):

my JS(file name: "test.js"):

$(document).ready(function() {
    $('div').fadeIn('slow');
});

控制台显示jQuery链接的加载时间为6.52秒.

The console is showing that the jQuery link is loading in 6.52s.

我还尝试链接到我在

<script src="C:\jQuery\jquery.js"></script> 

同样惨败...

但是我确实设法以某种方式链接了jQuery UI并运行了".accordion()" ... =/

I did however manage to link jQuery UI somehow and run ".accordion()"... =/

推荐答案

在这种情况下,您的test.js将不会运行,因为您要在jQuery之前加载它.放在jQuery之后:

In this case, your test.js will not run, because you're loading it before jQuery. put it after jQuery:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="test.js"></script>

这篇关于在HTML中链接jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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