【问题标题】:JS - having trouble getting text to change onclick?JS - 在获取文本以更改 onclick 时遇到问题?
【发布时间】:2022-06-13 05:34:44
【问题描述】:

我正在上在线课程,我复制了代码,但代码仍然无法正常工作。感谢您的帮助。

<html>

<head>
  <title>JavaScript</title>
</head>

<body>

  <p id="text">Javascript is hard.</p>

  <button id="myButton">Poop!</button>

  <script type="text/javascript">
    document.getElementById("myButton").onlclick = function() {

      document.getElementById("text").innerHTML =
        "You got this girl!";
    }
  </script>
</body>

【问题讨论】:

  • onlclick 应该是onclick

标签: javascript onclick


猜你喜欢
  • 2019-12-05
  • 2020-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-23
  • 2012-01-26
相关资源
最近更新 更多