JavaScript对象:JavaScript fontcolor() 方法

返回到:JavaScript对象:JavaScript String 对象

定义和用法

fontcolor() 方法用于按照指定的颜色来显示字符串。

该方法返回加了 <font> 标签的字符串, 如下所示:

<font color=”colorvalue”>string</font>

语法

string.fontcolor(color)

参数描述
color必需。为字符串规定 font-color。该值必须是颜色名(red)、RGB 值(rgb(255,0,0))或者十六进制数(#FF0000)。

所有主要浏览器都支持 fontcolor() 方法。

实例

使用绿色显示字符串:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Web176教程(Web176.com)</title> 
</head>
<body>

<script>
var txt = "Hello Web176!";
document.write("<p>字体变大: " + txt.big() + "</p>");
document.write("<p>字体缩小: " + txt.small() + "</p>");
document.write("<p>字体加粗: " + txt.bold() + "</p>");
document.write("<p>斜体: " + txt.italics() + "</p>");
document.write("<p>固定定位: " + txt.fixed() + "</p>");
document.write("<p>加删除线: " + txt.strike() + "</p>");
document.write("<p>字体颜色: " + txt.fontcolor("green") + "</p>");
document.write("<p>字体大小: " + txt.fontsize(6) + "</p>");
document.write("<p>下标: " + txt.sub() + "</p>");
document.write("<p>上标: " + txt.sup() + "</p>");
document.write("<p>链接: " + txt.link("https://www.Web176.com") + "</p>");
document.write("<p>闪动文本: " + txt.blink() + " (不能用于IE,Chrome,或者Safari)</p>");
</script>

</body>
</html>

作者:terry,如若转载,请注明出处:https://www.web176.com/javascriptbook/jsarrtips/3082.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2021年8月23日 下午3:45
下一篇 2021年8月23日 下午3:50

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注