--- title: String.prototype.bold() slug: Web/JavaScript/Reference/Global_Objects/String/bold tags: - Deprecated - HTML wrapper methods - JavaScript translation_of: Web/JavaScript/Reference/Global_Objects/String/bold ---
{{JSRef}} {{deprecated_header}}
bold()
方法会创建
HTML 元素 “b”,并将字符串加粗展示。
str.bold()
包含HTML元素 {{HTMLElement("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 |
---|---|---|
{{SpecName('ES6', '#sec-string.prototype.bold', 'String.prototype.bold')}} | {{Spec2('ES6')}} | Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers. |
{{SpecName('ESDraft', '#sec-string.prototype.bold', 'String.prototype.bold')}} | {{Spec2('ESDraft')}} | Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1.0")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("1.0")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |