我正在使用 d3 提示框,我想打印一个字符串。但是,我无法更改“索引”和“其他信息”之间的行。已经尝试过\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..."; });
最佳答案
您可以使用普通的 HTML 标签,例如 br
:
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) { return "index:<br> " + d.index + "other information..."; });
关于javascript - 如何在javascript中更改行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37617950/