【问题标题】:jQuery not working out of VScode, but does out of the Internet.. How can I fix this?jQuery 无法在 VScode 中运行,但无法在 Internet 中运行。我该如何解决这个问题?
【发布时间】:2020-12-30 09:43:40
【问题描述】:

我正在学习构建网站,目前我正在visual-studio代码内部编码,安装了大多数jQuery插件。

当我打开这个网址时:

http://www.completewebdevelopercourse.com/content/4-jquery/4.3.html

它的源代码与下面的代码相同, 我得到两个不同的结果。

一个,java脚本在其中工作(这是链接中的页面),另一个(存储在本地文件夹中并在VScode中打开),它不是。

我已经咨询了 VS-code 网站和论坛。没有运气,根本没有提到我的问题。只是似乎没有一个很好的jQuery插件,但我已经安装了sn-p-packages。

正常的 google-ling 给我的结果与上面提到的人们要求 jQuery 插件的结果相同

这怎么可能?我该如何解决?

[代码]

<!DOCTYPE html>
<head>
    
    <title>jQuery</title>

    <script type="text/javascript" src="jquery.min.js"></script>
    
    <style type="text/css">
    
        #circle {
            
            width: 150px;
            height: 150px;
            border-radius: 50%;
            background-color: green;
            margin: 10px;
            
        }
        
        .square {
            
            width: 150px;
            height: 150px;
            background-color: red;
            margin: 10px;
            
        }
    
    
    </style>
    
</head>

<body>
    
   <div id="circle"></div>
    
    <div class="square"></div>
    
    <div class="square"></div>
    
    
    <script type="text/javascript">
        
        $("div").click(function() {
            
            alert("a div was clicked!");
            
        });
        
        
        
        
        
        
    
        
    
    </script>
    
</body>

【问题讨论】:

    标签: javascript jquery visual-studio-code web-site-project


    【解决方案1】:

    确保你下载了 jquery.min.js 文件(你应该把它放在 html 页面的同一个文件夹中),否则它会变成 404。

    【讨论】:

    • 谢谢,但是404不是问题吗?但以防万一,只需下载并粘贴到文件夹中?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 2021-10-11
    • 1970-01-01
    • 2016-04-06
    • 2020-06-24
    • 1970-01-01
    相关资源
    最近更新 更多