我正在尝试更改标题颜色,因为我在下面的 html 代码中编写了该颜色以及颜色的颜色 文本的内容不会改变。 我该如何更改它?
/**
* Build a HTML table with the data
*/
Highcharts.Chart.prototype.getTable = function () {
var title =this.title.text;
var device = this.series[0].name;
var unit = this.series[0].yAxis.axisTitle.text;
// var html = '<table>',
var html = '<h1 style="color:red">'+title+'</h1> <h2 style="color:red" >Device: '+device+'</h2><h2 style="color:red" >Unit: '+unit+'</h2>'+
'<table>',
rows = this.getDataRows();
html += '</table>';
return html;
};
谢谢,米哈尔
最佳答案
使用以下代码而不是在 JavaScript 中编写 HTML 代码:
document.getElementById("Your_element_Id").style.color="Any_color";
关于javascript - 通过javascript代码更改html中的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27688500/