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

What's wrong with my textbox html code?

本文关键字:html 代码 有问题 文本 我的 什么      更新时间:2023-09-26

以下是代码:

<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>

我得到的只是第13行中的一个错误:未捕获类型错误:无法读取null的属性"value"。

我是这方面的新手,所以非常感谢您的帮助!谢谢

  1. 您在html中使用了智能引号。将"替换为"
  2. size=12:12不在引号中

Demo(在一些字符串文字之前或之后添加空格,使输出字符串更容易读取。)