gpt4 book ai didi

Jquery根本不会运行

转载 作者:行者123 更新时间:2023-12-01 03:42:38 24 4
gpt4 key购买 nike

我在使用 JQuery 时遇到问题。我正在尝试学习它,所以我将这个小网页放在一起进行测试,一切看起来都是正确的,但我仍然无法让它在 jsfiddle.net (它说它是有效代码)或我的计算机上工作.

<html>
<head>
<title>I listen to music</title>
<style>
#box
{
height:50px;
width:50px;
background-color:black;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#box").on('click', function () {
alert("hi");
});
});
</script>
</head>
<body>
<div id="box">asdf</div>
</body>
</html>

最佳答案

在 jsFiddle 上运行良好。

但是如果您在自己的系统上尝试它,则需要为 src 提供 httphttps。它不会在文件系统之外的 // 上工作,因为那样它将使用 file:// 协议(protocol),但在 jsFiddle 中它将使用 http .

<html>
<head>
<title>I listen to music</title>
<style>
#box
{
height:50px;
width:50px;
background-color:black;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#box").on('click', function () {
alert("hi");
});
});
</script>
</head>
<body>
<div id="box">asdf</div>
</body>
</html>

关于Jquery根本不会运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17731356/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com