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

标签 javascript html textbox

代码如下:

<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 的属性“值”。

我是新手,所以非常感谢帮助!谢谢。

最佳答案

  1. 您在 html 中使用了弯引号。将“”替换为“”。
  2. size=12:12 不在引号中。

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

关于javascript - 我的文本框 html 代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25826376/

相关文章:

javascript - 将 onclick 附加到 img 元素不起作用

html - XPath 选择该父 div 内的 <div> 的所有文本内容排除特定的 <div> 标记

javascript - 多个 jQuery 选择器的最佳语法实践

javascript - 在 jQuery 中从 URL 中获取#id

JavaScript错误: Permission denied to access property 'u8'

html - 无法在 Material Design Lite 的对话框模式中插入图像

c# - TextBox 的文本属性是否有可能为空?

c# - 如何将多行文本框作为一行保存到文本文件中?

c# - 在 WPF 中访问 XAML 控件

javascript - Backbone Collection 不使用它的模型