星期二, 十二月 15, 2009

IE getElementById display

Could not get the display property. Invalid argument

使用obj.style.display='none'
出现错误:
Could not get the display property. Invalid argument

function hider() {
var label, control;

if(document.getElementById && (label = document.getElementById('hidden1'))
&& (control = document.getElementById('hidden2'))
&& label.style && control.style)
{
label.style.display = control.style.display
= ('none' == label.style.display) ? '' : 'none';
}