使用javascript设置HTML文本颜色和大小 [英] set html text color and size using javascript

查看:177
本文介绍了使用javascript设置HTML文本颜色和大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在html中有以下代码行,如何使用Javascript以简单的方式以编程方式在MonitorInformationDIV元素内设置文本颜色和大小?对不起,我愚蠢,我想了很久,但无法弄清楚。 : -

 < div id =MonitorInformation>正在连接...等待< / div> 

预先感谢,
George

解决方案

  var elem = document.getElementById(MonitorInformation); 
elem.innerHTML =设置不同的HTML内容;
elem .style.color =Red;
elem.style.fontSize =large;


Suppose I have the following line of code in html, how to set the text color and size inside "MonitorInformation" DIV element in a programming way using Javascript in an easy way? Sorry for my stupid, I figured a long time but cannot figure out. :-(

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

thanks in advance, George

解决方案

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

这篇关于使用javascript设置HTML文本颜色和大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆