From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../reference/global_objects/string/sup/index.html | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/string/sup') diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html new file mode 100644 index 0000000000..118bbd1f2e --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html @@ -0,0 +1,118 @@ +--- +title: String.prototype.sup() +slug: Web/JavaScript/Reference/Global_Objects/String/sup +tags: + - String.prototype.sup() +translation_of: Web/JavaScript/Reference/Global_Objects/String/sup +--- +
{{JSRef}} {{deprecated_header}}
+ +

sup()方法创建 一个{{HTMLElement("sup")}}HTML 元素,使字符串显示为上标。

+ +

语法

+ +
str.sup()
+ +

返回值

+ +

包含{{HTMLElement("sup")}} HTML 元素的字符串。

+ +

描述

+ +

sup() 方法将字符串嵌入 <sup> 标签中:"<sup>str</sup>".

+ +

示例

+ +

使用sub()sup()方法

+ +

下面的示例使用了{{jsxref("String.prototype.sub()", "sub()")}}和sup()方法来格式化字符串:

+ +
var superText = 'superscript';
+var subText = 'subscript';
+
+console.log('This is what a ' + superText.sup() + ' looks like.');
+// "这就是<sup>superscript</sup>的样子。"
+
+console.log('This is what a ' + subText.sub() + ' looks like.');
+// "这就是<sub>subscript</sub>的样子。"
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES6', '#sec-string.prototype.sup', 'String.prototype.sup')}}{{Spec2('ES6')}}初始定义。在 JavaScript 1.0 中实现。在(规范性)附件 B 中定义为用于 Web 浏览器的 ECMAScript 附加特性。
{{SpecName('ESDraft', '#sec-string.prototype.sup', 'String.prototype.sup')}}{{Spec2('ESDraft')}}在(规范性)附件 B 中定义为用于 Web 浏览器的 ECMAScript 附加特性。
+ +

浏览器兼容性

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

另见

+ + -- cgit v1.2.3-54-g00ecf