简体   繁体   English

有人请解释这个JavaScript

[英]Someone please explain this javascript

http://codepen.io/anon/pen/JdRJGz http://codepen.io/anon/pen/JdRJGz

I've tried for a while and it seems that the script is simply not running. 我尝试了一段时间,似乎脚本根本没有运行。 I'm sure that I have js enabled , maybe there's a bug i didn't catch? 我确定我启用了js,也许有一个我没有发现的错误?

function hello(){
``getElementById("message").style.display="block";
  getElementById("block").style.display="block";
};

function disappear(){
  getElementById("message").style.display="none";
  getElementById("block").style.display="none";
};

If you would open up the developer console, you'd see the problem immediately: getElementById() is not defined. 如果您打开开发人员控制台,则会立即看到问题:未定义getElementById() You're looking for 您正在寻找

  document.getElementById("message").style.display = "block";

getElementById is a member of the Document object getElementByIdDocument对象的成员

Correct your code like 更正您的代码

function hello(){
    document.getElementById("message").style.display="block";
    document.getElementById("block").style.display="block";
};

function disappear(){
    document.getElementById("message").style.display="none";
    document.getElementById("block").style.display="none";
};

http://codepen.io/anon/pen/OVRgmW http://codepen.io/anon/pen/OVRgmW

here let me explain,this hello and disappear r two functions which will trigger when u do an event like button click or something in ur code, message is an id of an element u set in ur page, n ur calling it specifically using its id and ur setting its style. 这里让我解释一下,这是您好和消失r这两个函数,当您执行按钮单击之类的事件或您的代码中的某些事件时会触发,消息是您在页面中设置的元素的ID,您将使用其ID专门调用它并设置其样式。 I dont knw how u want ur code to behave but with the given information this is the best assumption i can make. 我不知道您希望您的代码如何运行,但是根据给定的信息,这是我能做出的最佳假设。

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

相关问题 有人可以解释这些javascript概念吗? - Could someone please explain theses javascript concepts? 有人可以解释这个 JavaScript 代码吗? - Can someone explain this JavaScript code please? 有人可以解释一下这段JavaScript代码的作用吗? - Can someone please explain what this bit of javascript code is doing? 有人可以解释一下这个javascript代码(与ajax有关)吗? - Can someone please explain this javascript code (related to ajax)? 有人可以帮我解释这个JavaScript正则表达式吗? - Can someone please explain this JavaScript regular expression for me? 有人可以解释一下此JavaScript代码中发生了什么吗? - can someone please explain what is happening in this javascript code? 有人可以详细解释这个JavaScript十进制舍入函数吗? - Can someone please explain this JavaScript decimal rounding function in detail? 有人可以向我解释Java中“ |”符号的作用吗? - Can someone please explain to me what the “|” symbol is doing in Javascript? 有人可以解释以下javascript代码段吗? (菜鸟) - Can someone please explain the following javascript code snippets? (NOOB) 有人可以在 JavaScript 中解释我的 params 数组的类型吗? - Can someone please explain the type of params array in my case in JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM