抱歉,如果之前有人问过这个问题,但我找不到任何东西。我正在 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>
它不能正常工作。它应该在按下按钮时更改文本,但事实并非如此。这是怎么回事?
原文由 Hobgoblin8 发布,翻译遵循 CC BY-SA 4.0 许可协议
你需要导入:
例子: