gpt4 book ai didi

Javascript 在 HTML 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 13:59:31 25 4
gpt4 key购买 nike

很抱歉,如果之前有人问过这个问题,但我找不到任何东西。我正在 Free Code Camp 学习 Javascript 编码。当我尝试为自己使用他们的代码时...

<!DOCTYPE html>


<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
$(document).ready(function() {
$("#getMessage").on("click", function(){
// Only change code below this line.
$(".message").html("Here is the message");
// Only change code above this line.
});
});
</script>


<div class="container-fluid">
<div class = "row text-center">
<h2>Cat Photo Finder</h2>
</div>
<div class = "row text-center">
<div class = "col-xs-12 well message">
The message will go here
</div>
</div>
<div class = "row text-center">
<div class = "col-xs-12">
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</div>
</div>
</div>

</body>
</html>

它没有正常工作。它应该在按下按钮时更改文本,但事实并非如此。怎么回事?

最佳答案

It doesn't work as it should. It should change text when the button is pressed but it doesn't. What's going on?

你需要导入:

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

示例:

<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>

关于Javascript 在 HTML 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42987902/

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