高亮代码
var theObj; function hoverIt(obj) { if (theObj != null) { theObj.style.background = "#fff"; } if (theObj = obj) { obj.style.background = "red"; } }
HTML代码
<div> <span onclick="hoverIt(this)">菜单一</span> <span onclick="hoverIt(this)">菜单二</span> <span onclick="hoverIt(this)">菜单三</span> <span onclick="hoverIt(this)">菜单四</span> </div>
Done!