JavaScript对象:JavaScript sub() 方法

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

定义和用法

sub() 方法用于把字符串显示为下标。

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

<sub>string</sub>

语法

string.sub()

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

实例

把字符串显示为下标:

<!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/3100.html

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

相关推荐

发表回复

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