在infowindow中使标题变为粗体

时间:2018-05-15 03:19:35

标签: javascript html xml

嗨,专家我只想询问如何使我的信息窗口的标题变粗或变强。我的代码是这样的。帮帮我专家。

var name = markerElem.getAttribute('name');
var infowincontent = document.createElement('div');
              var strong = document.createElement('strong'); 
              strong.textContent = name
              infowincontent.appendChild(strong);
              infowincontent.appendChild(document.createElement('br'));

但它并没有在我的信息窗口中使这个名字变得大胆。

3 个答案:

答案 0 :(得分:1)

您可以将html与谷歌地图信息窗口一起使用,如下所示:

var contentString = '<strong>My title</strong>';
var infowindow = new google.maps.InfoWindow({
      content: contentString
});

此外,您可以在此处找到完整示例:https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple

答案 1 :(得分:0)

我刚把它添加到我的代码中,它已经变成了粗体。

strong.style.fontWeight = 'bold';

答案 2 :(得分:-1)

<body>
<div id="wrapper" name="yourname">hello</div>
<script>
// makerelem
var markerElem = document.getElementById('wrapper');

var name = markerElem.getAttribute('name');
var infowincontent = document.createElement('div');
var strong = document.createElement('strong');
strong.textContent = name
infowincontent.appendChild(strong);
infowincontent.appendChild(document.createElement('br'));

// add in document
document.body.appendChild(infowincontent);

</script>
</body>

代码结果:
Code result

相关问题