【发布时间】:2013-09-23 17:22:03
【问题描述】:
我想在右键单击标记时显示一个信息窗口。
infoWindow 必须根据值显示 4 个复选框。
google.maps.event.addListener(marker,"rightclick", function()
{
html = "<table><tr><td>";
if (value1==...)
{
html = html + "<input type='checkbox' id='option1' checked>value1<br>";
}
else
{
html = html + "<input type='checkbox' id='option1'>value1<br>";
}
if (value2==...)
{
html = html + "<input type='checkbox' id='option2'checked>value2<br>";
}
else
{
html = html + "<input type='checkbox' id='option2' >value2<br>";
}
if (value3==...)
{
html = html + "<input type='checkbox' id='option3' checked>value3<br>";
}
else
{
html = html + "<input type='checkbox' id='option3' >value3<br>";
}
if (value4==...)
{
html = html + "<input type='checkbox' id='option4' checked>value4<br>";
}
else
{
html = html + "<input type='checkbox' id='option4' >value4<br>";
}
html = html + "</td></tr></table>";
marker.setContent(html)
infoWindow.open(map,marker);
});
1) 是否因为这段代码不优雅而使用 jquery 实现了更好的实现?
2)如果我点击复选框#N,如何修改对应valueN的值?
【问题讨论】:
-
dafuq 为什么不
+=和为什么不 SWITCH!!!? -
如果要测试不同的变量,如何使用 switch?
-
可以使用 switch 和 += 以及 jquery 呢?
标签: javascript jquery html google-maps-api-3