我有json,其格式如下所示
<p>jellp</p>
我如何使用javascript应用样式?现在我正在使用
cell.appendChild(document.createTextNode(data['data']['timeline'][i]['content'][j]['title'] ));
答案 0 :(得分:1)
在任何DOM节点上使用.style.{property}
。例如,这会将段落中的文本着色为红色:
var p = document.createTextNode(data['data']['timeline'][i]['content'][j]['title']);
p.style.color = "red";
cell.appendChild(p);