JavaScript html编辑错误

use*_*631 -1 html javascript css

我是JS的新手,只是编写一些脚本来学习.有人能告诉我我在哪里错了吗?我认为它可能只是一个语法错误或我没有使用正确的功能来完成这项任务.

谢谢 :)

HTML:

<!DOCTYPE html>
<html>
<head>
<title>javascript &#8226; training</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
    <div id='textOff'>
        Hi there this is some sample text for my JS
    </div>
    <input type='submit' value='show me some stuff!' onclick='show();'/>
    <script>
    function show() {
        var text = document.getElementByID('textOff');
        console.log(text); //debugging
        text.id = 'mainText';
    };
    </script>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

CSS:

body {
    background-color: #17161F;
    color: white;
}

#mainText {
    width: 20%;
    height: 30%;
    font-family: Arial;
    margin-left: 20%;
    margin-top: 20%;
}

#textOff {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

Que*_*tin 6

JavaScript区分大小写.

 getElementById // correct
 getElementByID // incorrect
Run Code Online (Sandbox Code Playgroud)

使用浏览器提供的JavaScript控制台:

TypeError:对象#<HTMLDocument>没有方法' getElementByID'