小编Mar*_*rck的帖子

提示框不起作用

其他3个按钮正常运行,但最后一个按钮是一个可以输入特定颜色进行更改的按钮不起作用.我已经尝试过并检查过,除非我真的很胖并且看不出有什么问题...如果我没有看到如此明显的东西,请提前抱歉.

    <html>
    <head>
    <title>FA2</title>
    </head>
    <body>
    <h1 id=js>JavaScript</h1>
    <script>
    function show(){
       document.getElementById("js").innerHTML="is a Programming Language"}
    
    function reset(){
       document.body.style.backgroundColor="white";
       document.getElementById("js").innerHTML="JavaScript"}
    
    function red(){
       document.body.style.backgroundColor="red"}
    
    function green(){
       document.body.style.backgroundColor="green"}
    
    function blue(){
       document.body.style.backgroundColor="blue"}
      
    function type(){
       var color = prompt("Enter Color");
       document.body.style.backgroundColor = color}
    </script>
    
    <style type="text/css">
    
    body
    {
    text-align:center;
    font-family:Arial;
    }
    
    </style>
    
    <button onclick="show()">Show</button>
    <button onclick="reset()">Reset</button>
    <hr>
    
    Change Background:
    <button onclick="red()">Red</button>
    <button onclick="green()">Green</button>
    <button onclick="blue()">Blue</button>
    <button onclick="type()">Type Color</button>
    <hr>
    </body>
    </html>
Run Code Online (Sandbox Code Playgroud)

Chrome中的控制台显示错误:

未捕获的TypeError:type不是函数

javascript

2
推荐指数
1
解决办法
211
查看次数

标签 统计

javascript ×1