var buttonArray = [
document.getElementById('underline'),
document.getElementById('bold'),
document.getElementById('italic'),
document.getElementById('tnr'),
document.getElementById('ss'),
document.getElementById('red'),
document.getElementById('green'),
document.getElementById('blue')
];
你能做到吗?还是太抽象了?
答案 0 :(得分:2)
是;这将很好。
你可以让它更优雅:
var buttonArray = [ "underline", ... ]
.map(document.getElementById.bind(document));