此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

String.prototype.big()

Deprecated

Avoid using this feature in new projects. HTML wrapper methods exist only for backwards compatibility. Use DOM APIs to create elements instead. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: DOM.

String 值的 big() 方法创建一个 <big> 元素字符串,其中嵌入了调用的字符串(<big>str</big>),从而使该字符串以大字体显示。

备注:所有的 HTML 包装方法都已被弃用,并且仅为了兼容性而标准化。对于 big() 方法来说,在 HTML5 中已经移除了 <big> 元素,不应再使用它。Web 开发者应该使用 CSS 属性来实现相应的效果。

语法

js
big()

参数

无。

返回值

一个以 <big> 开始标签开头的字符串,然后是文本 str,最后是 </big> 结束标签。

示例

使用 big()

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

js
const 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</font>

使用 element.style 对象,你能更通用地获得和操作该元素的 style 属性,例如:

js
document.getElementById("yourElemId").style.fontSize = "2em";

规范

规范
ECMAScript® 2027 Language Specification
# sec-string.prototype.big

浏览器兼容性

参见