if (this.firstChild.style.display == 'none')
{this.firstChild.style.display = 'block'}
else
{this.firstChild.style.display = 'none'};
是否可以使用变量来缩短此代码?
最佳答案
你可以像这样缩短它:
var a = this.firstChild.style;
a.display = (a.display=='none'?'block':'none');
关于javascript - 使用变量简化 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10663528/