javascript - 使用javascript设置html文本颜色和大小

标签 javascript html

假设我在 html 中有以下代码行,如何使用 Javascript 以编程方式轻松地设置“MonitorInformation”DIV 元素内的文本颜色和大小?对不起我的笨蛋,我想了很久还是想不通。 :-(

<div id="MonitorInformation">Connecting...wait</div>

提前致谢, 乔治

最佳答案

var elem = document.getElementById("MonitorInformation");
elem.innerHTML = "Setting different HTML content";
elem.style.color = "Red";
elem.style.fontSize = "large";

关于javascript - 使用javascript设置html文本颜色和大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1188843/

相关文章:

javascript - 将变量传递给 promise 的函数

JavaScript + addEventListener 'click' 在选择的 html 对象上被忽略

javascript - rails : hide/close a rendered partial through a button in that partial

html - CSS image.png 未加载到谷歌驱动器

css - 我无法将一个 DIV float 到另一个 DIV 旁边的问题

javascript - 将背景扩展到屏幕边缘

javascript - 如何使用 contenteditable 获取 div 元素内标记文本的父元素?

html - 使用 *page-level* 滚动条滚动 DIV(其高度设置为可见区域)

javascript - Flexbox 仅适用于 Chrome

html - CSS 背景图片不显示