[英]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 getElementById是
Document
对象的成员
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.