我正在尝试使用文本和图标更新 HTML 表格行元素。这是我迄今为止尝试过的:
const cell = document.getElementById("cellID");
if (true) { cell.innerHTML = {someText} {<i className="fa fa-exclamation-circle fa-fw" />} }
这里,cell
是 HTML 表格中的一个单元格。例如,<td id="someId">some text</td>
我可以轻松地更新文本,cell.textContent = 'newText'
但是当我尝试在文本旁边添加图标时它不起作用。这没用。如何添加带有文本的图标?
您是否尝试过使用模板文字
if (true) {
cell.innerHTML = `${someText} <i class="fa fa-exclamation-circle fa-fw" />`
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句