String.prototype.bold()

已废弃
该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。

bold() 方法会创建 HTML 元素 “b”,并将字符串加粗展示。

语法

str.bold()

返回值

包含HTML元素 <b> 的字符串。

描述

bold() 方法将一个字符串嵌入到<b></b>标记中。

示例

使用bold()

下面的例子使用字符串方法来改变字符串的格式。

var worldString = 'Hello, world';

console.log(worldString.blink());   // <blink>Hello, world</blink>
console.log(worldString.bold());    // <b>Hello, world</b>
console.log(worldString.italics()); // <i>Hello, world</i>
console.log(worldString.strike());  // <strike>Hello, world</strike>

规范

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
String.prototype.bold
Standard Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.
ECMAScript Latest Draft (ECMA-262)
String.prototype.bold
Draft Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)

相关连接