function changeColor(dom,color,bg) {
dom.style.color = color;
dom.style.background = bg;
}
var spans = document.getElementsByTagName('span');
spans[0].onmouSEOver = function() {
changeColor(this,'red','#ddd');
}
spans[0].onmouSEOut = function() {
changeColor(this,'#333','#f5f5f5');
}
spans[1].onmouSEOver = function() {
changeColor(this.getElementsByTagName('strong')[0],'#ddd');
}
解耦,提取共同点