This should be real simple... But it ain't... >.<
var x = document.getElementById('x');
function snooze()
{
x.style.height = '10px';
}
Upon execution, the error I get is:
TypeError: Result of expression 'x' [null] is not an object.
Edit: Heads up, it works when I put the var declaration inside the function. I don't understand... :-(
function snooze()
{
var x = document.getElementById('x');
x.style.height = '10px';
}
Either:
id="x".If an element with id="x" exists, try:
window.onload = function () {
// your code in here
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With