如何在javascript中更改行

时间:2016-06-03 15:13:54

标签: javascript d3.js

我正在使用d3提示框,我想打印一个字符串。但是,我不能改变我的索引与#39;之间的界限。和其他信息'。已经尝试了\ r,\ n,\ r \ n,但它们都不起作用。

谢谢!

我的代码是:



  // Show additional infomation in the tip
  var tip = d3.tip()
      .attr('class', 'd3-tip')
      .offset([-10, 0])
      .html(function(d) { return "index: " + d.index + "other information..."; });




1 个答案:

答案 0 :(得分:1)

您可以使用普通的HTML标记,例如br

 var tip = d3.tip()
  .attr('class', 'd3-tip')
  .offset([-10, 0])
  .html(function(d) { return "index:<br> " + d.index + "other information..."; });