在InfoWindow.content中插入样式HTML表
Inserting Styled HTML Table inside InfoWindow.content?
问候花儿,
我正在使用谷歌地图API构建一些工具
我想插入一些样式的HTML表格,而不是纯文本
但我没有成功。有什么想法吗?谢谢!
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
table.colorful {
font-family: verdana, arial, sans-serif;
font-size: 11px;
color: #333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
table.colorful th {
background: #b5cfd2 url('blueCell.jpg');
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #999999;
}
table.colorful td {
background: #dcddc0 url('greenCell.jpg');
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #999999;
}
#mapCanvas { height: 100% }
</style>
:
var info = new google.maps.InfoWindow({
position: dcs[i].coord,
content: ""
});
info.content = "<table class='"table.colorful'"><tr><th>Server</th><th>Site</th><th>IP</th><th>Services</th></tr>"
for(var j in dcs[i].servers) {
info.content += "<tr><td><b>" + dcs[i].servers[j].name + "</b></td><td>" + dcs[i].servers[j].site + "</td><td>" + dcs[i].servers[j].ip + "</td><td>" + dcs[i].servers[j].services + "</td></tr>";
}
info.content += "</table>";
你是如此接近,你需要使用info.setContent()来代替。
info.setContent(element);
相关文章:
- 一个正则表达式,用于从JS中的HTML标记中删除id、样式和类属性
- 如果类不是一个选项,如何在使用 jQuery 时控制(避免)嵌套 html 元素的样式
- 应用程序在呈现Jquery Mobile之前显示无样式的Html
- ID为的HTML样式类
- 样式<身体>并且<html>来自React
- 使用jQuery按条件将样式设置为html标记
- 使用 javascript 重置 html 所需的样式
- 无法通过内容脚本使用jQuery更改HTML元素的样式
- 在呈现HTML样式和脚本时加载启动页
- HTML + JS:设置文本区域内容样式的最佳方式
- 无法“替换”样式“中的内容 - 其中”html“存储在变量中
- 为html标记定义自定义css样式
- JS(ajax)数组-带有HTML的输出和样式
- 具有固定顶行和左列的Excel样式HTML表格的更好实现?(jsFiddle 示例)
- 样式 HTML 元素,后跟特定类
- 显示和样式HTML源代码在HTML页面
- 如何样式html上传按钮,仍然有文字在一边
- 如何样式HTML选择选项悬停和选择选项效果
- 自定义光标使用 CSS 样式 - html/css - javascript
- 在InfoWindow.content中插入样式HTML表