这应该是非常简单的...但它不是......>.<
var x = document.getElementById('x');
function snooze()
{
x.style.height = '10px';
}
Run Code Online (Sandbox Code Playgroud)
执行时,我得到的错误是:
TypeError: Result of expression 'x' [null] is not an object.
编辑:抬头,当我将var声明放在函数中时,它可以工作.我不明白...... :-(
function snooze()
{
var x = document.getElementById('x');
x.style.height = '10px';
}
Run Code Online (Sandbox Code Playgroud)
Dav*_*ang 12
或者:
id="x".如果元素id="x"存在,请尝试:
window.onload = function () {
// your code in here
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14998 次 |
| 最近记录: |