2019-04-21 11:50:48 +08:00

101 lines
5.6 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<article id="wikiArticle">
<div> <div class="blockIndicator deprecated deprecatedHeader">
<p><strong><span class="icon-only-inline" title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> 已废弃</strong><br/>该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。</p>
</div></div>
<p>The <strong><code>italics()</code></strong> method creates an <a href="/zh-CN/docs/Web/HTML/Element/i" title="HTML元素 &lt;i&gt; 用于表现因某些原因需要区分普通文本的一系列文本。例如技术术语、外文短语或是小说中人物的思想活动等,它的内容通常以斜体显示。"><code>&lt;i&gt;</code></a> HTML element that causes a string to be italic.</p>
<h2 id="Syntax">Syntax</h2>
<pre><code class="language-javascript"><code><var>str</var>.italics()</code></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><code class="language-javascript">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></code></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><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.italics" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">String.prototype.italics</small></a></td>
<td><span class="spec-Standard">Standard</span></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><a class="external" href="https://tc39.github.io/ecma262/#sec-string.prototype.italics" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">String.prototype.italics</small></a></td>
<td><span class="spec-Draft">Draft</span></td>
<td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div></div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td>1.0 (1.7 or earlier)</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td>1.0 (1.0)</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="Reference/Global_Objects/String/blink" title="blink()方法创建使字符串闪烁的 &lt;blink&gt; HTML 元素。"><code>String.prototype.blink()</code></a></li>
<li><a href="Reference/Global_Objects/String/bold" title="bold() 方法会创建 HTML 元素 “b”并将字符串加粗展示。"><code>String.prototype.bold()</code></a></li>
<li><a href="Reference/Global_Objects/String/strike" title="strike()方法创建&lt;strike&gt; HTML 元素,使字符串展示为被删除的文本。"><code>String.prototype.strike()</code></a></li>
</ul>
</article>