[英]Why won't my function execute?
I have this code, and body 我有这段代码,身体
<body onload="mail_receive()">
won't execute it. 不会执行。
function mail_receive() {
document.getElementById("w")="mail receive";
}
It won't show in 它不会显示在
<div id="w"></div>
You can't assign a string value to a DOM element and expect it to work. 您不能将字符串值分配给DOM元素并期望它起作用。 (In fact you probably can't use the result of a function call as an lvalue in Javascript to begin with.)
(实际上,您可能无法将函数调用的结果用作Javascript中的左值。)
Try 尝试
document.getElementById('w').innerHTML = 'Mail received';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.