String.prototype.small()

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

small() 方法的作用是创建一个使字符串显示小号字体的 <small> 标签。

语法

str.small()

返回值

带有 <small> 标签的字符串。

描述

small() 方法会 将一个字符串嵌入到<small> 标签中: "<small>str</small>"

示例

使用 small() 函数

为了改变一个字符串的字体大小,下面的例子使用了字符串中的方法:

var worldString = 'Hello, world';

console.log(worldString.small());     // <small>Hello, world</small>
console.log(worldString.big());       // <big>Hello, world</big>
console.log(worldString.fontsize(7)); // <font size="7">Hello, world</fontsize>

使用element.style (en-US)对象,你能更加一般地获得和操作该元素的属性,比如:

document.getElementById('yourElemId').style.fontSize = '0.7em';

规范

Specification
ECMAScript Language Specification
# sec-string.prototype.small

浏览器兼容性

BCD tables only load in the browser

相关链接