我添加自定义div元素到我的谷歌地图使用代码从这里http://code.google.com/apis/maps/documentation/javascript/controls.html#CustomExample我有3-4个按钮,我如何突出显示最后点击?
发布于 2011-11-12 18:02:55
在追加之前,在所有自定义按钮的控件边框中添加一个类名。例如:
controlUI.className = 'button';添加一个函数来突出显示当前的自定义按钮:
function hightlightButton(oElement) {
var aButtons = document.getElementsByClassName('button');
for (var i = 0; i < aButtons.length; i++) {
aButtons[i].style.backgroundColor = "white";
}
oElement.style.backgroundColor = "yellow";
}在单击处理程序中,添加以下行以调用新函数:
hightlightButton(this);另请参阅我的jsfiddle。
https://stackoverflow.com/questions/8103494
复制相似问题