简体   繁体   English

当我点击按钮时,我不知道怎么了

[英]I don't know what's wrong when i click the button nothing work

var zer = document.getElementById("zer");

zer.addEventListener("click", function(){

document.getElementById("info").innerHTML = "Hello World";    
})

Hope you get where you were wrong. 希望你能找到你错的地方。

The best practice is to keep the scripts at the end so that all the html code is loaded and then the scripts are loaded. 最佳做法是将脚本保留在末尾,以便加载所有html代码,然后再加载脚本。

      <!DOCTYPE html>
      <html>
      <head>
      <link href="style.css" rel="stylesheet">
      </head>
      <body> 
        <div id="container">
          <button id="zer" >click here</button>
          <div id="info"></div>
         </div>
        <script src="script.js"></script>
        <script src="jquery-3.3.1.min.js">
      </body>
       </html>

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

相关问题 我不知道“渲染”有什么问题 - I don't know what's wrong with 'render' 我不知道联系表有什么问题 - I don't know what's wrong with contact form 为什么单击按钮时脚本不起作用? - Why scripts don't work when I click on a button? 我不知道我的编码有什么问题。 (javascript) - I don't know what's wrong with my coding. (javascript) 我不知道我做错了什么,它不起作用,我正在尝试列出任务清单 - i don't know what i did wrong, it doesn't work, i'm trying to make a task list 如果我不知道 Selenium 中的 ID 是什么,如何单击已生成 ID 的元素 - How to click elements that have generated id's if I don't know what the ID will be in Selenium 我不知道要在此代码中更改什么才能使其正常工作 - I don't know what to change in this code for it to work 我不知道我做错了什么,我想在页面滚动时更改导航栏的背景颜色 - I don't know what i am doing wrong, I want to change the background color of the navbar when the page gets scrolled 我在制作 loginPage 时从控制台收到错误,但我不知道出了什么问题(React.js) - i got error from console while making loginPage but i don't know what's wrong (React.js) 我的Javascript不起作用。不知道它是函数,我是如何调用它,我使用的CSS或者是什么 - My Javascript doesn't work. Don't know if it's the Function, how I'm calling it, the CSS I used or what
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM