Javascript 部分使工具提示文本加粗

Javascript 部分使工具提示文本加粗,javascript,d3.js,tooltip,Javascript,D3.js,Tooltip,我正在尝试将工具提示中的第一行文本设置为粗体。 下面的代码是我目前拥有的,它不起作用 tooltip.html("<b>" + smartData[yearSlider][d3.select(this).attr("country")]["country"] + "</b> <br>" + "Total CO2 Emission excluding LULUCF&

我正在尝试将工具提示中的第一行文本设置为粗体。 下面的代码是我目前拥有的,它不起作用

  tooltip.html("<b>" + smartData[yearSlider][d3.select(this).attr("country")]["country"] + "</b> <br>" +
  "Total CO2 Emission excluding LULUCF" + "<br>" + 
  smartData[yearSlider][d3.select(this).attr("country")]["totalghgexlulucf"] + 
  "<br>" + "Total CO2 Emission including LULUCF" + "<br>" +
  smartData[yearSlider][d3.select(this).attr("country")]["totalghginclulucf"] +
  "<br>")
  
tooltip.html(“+smartData[yearSlider][d3.选择(this.attr(“country”)][“country”]+”
”+ “不包括土地利用、土地利用的变化和林业的二氧化碳排放总量”+“
”+ smartData[yearSlider][d3.选择(此).attr(“国家”)][“totalghgexlulucf”]+ “
”+“包括土地利用、土地利用的变化和林业在内的二氧化碳排放总量”+“
”+ smartData[yearSlider][d3.选择(this).attr(“国家”)][“totalghginclulucf”]+ “
”)
下面的屏幕截图是上面代码的结果(一些CSS用于设置工具提示的样式,等等)

有人能帮我吗? 如果您需要更多的代码来帮助我解决这个问题,我非常乐意与您分享!:)

对不起,我的英语不好,它不是我的母语。
提前谢谢你

您好,您可以通过在css文件中使用带有类的span并设置该类的样式来解决此问题:

tooltip.html("<span class='tooltip-text-bold'>" + smartData[yearSlider][d3.select(this).attr("country")]["country"] + "</span> <br>" +
  "Total CO2 Emission excluding LULUCF" + "<br>" + 
  smartData[yearSlider][d3.select(this).attr("country")]["totalghgexlulucf"] + 
  "<br>" + "Total CO2 Emission including LULUCF" + "<br>" +
  smartData[yearSlider][d3.select(this).attr("country")]["totalghginclulucf"] +
  "<br>")

您的标记没有结束标记您是否在html项目中或通过JS工具提示初始化设置了
data html=“true”
?您是否也可以提供用于创建工具提示的代码?
.tooltip-text-bold{
    font-weight: 700;
}