aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/string/italics/index.html
blob: d94a82229dd34718e86d528b90aa35b2d410c979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: String.prototype.italics()
slug: Web/JavaScript/Reference/Global_Objects/String/italics
translation_of: Web/JavaScript/Reference/Global_Objects/String/italics
---
<div>{{JSRef}} {{deprecated_header}}</div>

<p>The <strong><code>italics()</code></strong> method creates an {{HTMLElement("i")}} HTML element that causes a string to be italic.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox"><code><var>str</var>.italics()</code></pre>

<h2 id="Description">Description</h2>

<p>The <code>italics()</code> method embeds a string in an <code>&lt;i&gt;</code> tag: <code>"&lt;i&gt;str&lt;/i&gt;"</code>.</p>

<h2 id="Examples">Examples</h2>

<h3 id="Using_italics()">Using <code>italics()</code></h3>

<p>The following example uses string methods to change the formatting of a string:</p>

<pre class="brush: js">var worldString = 'Hello, world'; console.log(worldString.blink());  // Hello, world
console.log(worldString.bold());  // <strong>Hello, world</strong>
console.log(worldString.italics()); //<em>Hello, world</em>
console.log(worldString.strike());  // <s>Hello, world</s></pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-string.prototype.italics', 'String.prototype.italics')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-string.prototype.italics', 'String.prototype.italics')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

{{Compat}}

<h2 id="See_also">See also</h2>

<ul>
 <li>{{jsxref("String.prototype.blink()")}}</li>
 <li>{{jsxref("String.prototype.bold()")}}</li>
 <li>{{jsxref("String.prototype.strike()")}}</li>
</ul>