未捕获的引用错误-未定义functionName

时间:2019-01-27 14:35:34

标签: javascript html

这是我的HTML文件

<!DOCTYPE html>
<html lang="e">
<head>
<meta charset="UTF-8">
<title> Practice Java Script </title>
<link rel="stylesheet" href="cssjs/csspracticejs.css">
<script scr="javajs/java.js"></script>
</head>
<body>
<h1>Changing the Style</h1>
<p>JavaScript can change the style of an HTML element.</p>
<button type="button" onclick="openMe()">Open!</button>
<button type="button" onclick="closeMe()">Close!</button>
<p id="demo">Extra details...You can open and close this paragraph using the 
buttons above.</p>
</body>
</html>

这是我的JavaScript

    function closeMe(){
    x=document.getElementById("demo");
    x.style.display="none";
}

    function openMe(){
    x=document.getElementById("demo");
     x.style.display="block";}

但是当我尝试运行它时,它显示为Uncaught ReferenceError:HTMLButtonElement.onclick(HTML.html:13)上未定义closeMe。你能帮我看看我做错了什么吗?

1 个答案:

答案 0 :(得分:0)

导入脚本时出现拼写错误。

应为<script src>而不是<script scr>