简体   繁体   English

我的文本框html代码有什么问题?

[英]What's wrong with my textbox html code?

Here is the code: 这是代码:

<html>
<head>
    <title> Welcome Page </title>
</head>

<body>
    <h1>Greetings</h1>
    <p>
        Enter your name: <input type=“text” id=“nameBox” size=12 value="">
    </p>
    <input type="button" value="Click for Greeting"
        onclick="document.getElementById('outputDiv').innerHTML='hello' + document.getElementById('nameBox').value + ', welcome to my page.<br>Do you mind if I call you' + document.getElementById('nameBox').value + '?';">
    <hr>
    <div id=“outputDiv”></div>
</body>

All I'm getting is an error in line 13: Uncaught TypeError: Cannot read property 'value' of null. 我所得到的只是第13行中的错误:未捕获的TypeError:无法读取null的属性“值”。

I'm new to this, so help would be very much appreciated! 我对此并不陌生,因此非常感谢您的帮助! Thanks. 谢谢。

  1. You are using smart quotes in your html. 您在HTML中使用智能引号。 Replace “” with "". 用。。。来代替 ””。
  2. size=12 : 12 isn't in quotes. size=1212没有引号。

Demo (Added spaces before or after some string literals to make output string easier to read.) 演示 (在某些字符串文字之前或之后添加空格,以使输出字符串更易于阅读。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM