Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-cn]: Update translation of String.small() #15375

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,39 @@ slug: Web/JavaScript/Reference/Global_Objects/String/small

{{JSRef}} {{deprecated_header}}

**`small()`** 方法的作用是创建一个使字符串显示小号字体的 {{HTMLElement("small")}} 标签。
{{jsxref("String")}} 值的 ** `small()` ** 方法创建一个 {{HTMLElement("small")}} 元素字符串,并将调用字符串嵌入其中(`<small>str</small>`),从而使该字符串以小号字体显示。

> **备注:** 所有 [HTML 包装方法](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#html_包装器方法)都已被弃用,并且仅为了兼容性而标准化。请使用[DOM API](/zh-CN/docs/Web/API/Document_Object_Model)(例如 [`document.createElement()`](/zh-CN/docs/Web/API/Document/createElement))代替。
yin1999 marked this conversation as resolved.
Show resolved Hide resolved

## 语法

```plain
str.small()
```js-nolint
small()
```

### 返回值
### 参数

带有 {{HTMLElement("small")}} 标签的字符串

## 描述
### 返回值

`small()` 方法会 将一个字符串嵌入到`<small>` 标签中: `"<small>str</small>"`
一个以 `<small>` 开始标签开头的字符串,接着是文本 `str`,最后是 `</small>` 结束标签

## 示例

### 使用 `small()` 函数
### 使用 small()

为了改变一个字符串的字体大小,下面的例子使用了字符串中的方法
以下示例使用字符串方法更改字符串的大小

```js
var worldString = "Hello, world";
const worldString = "Hello, world";

console.log(worldString.small()); // <small>Hello, world</small>
console.log(worldString.big()); // <big>Hello, world</big>
console.log(worldString.fontsize(7)); // <font size="7">Hello, world</fontsize>
```

使用{{domxref("HTMLElement.style", "element.style")}}对象,你能更加一般地获得和操作该元素的属性,比如
使用 {{domxref("HTMLElement/style", "element.style")}} 对象,你可以获取元素的 `style` 属性并以更通用的方式进行操作,例如

```js
document.getElementById("yourElemId").style.fontSize = "0.7em";
Expand All @@ -49,7 +51,8 @@ document.getElementById("yourElemId").style.fontSize = "0.7em";

{{Compat}}

## 相关链接
## 参见

- [`core-js` 中 `String.prototype.small` 的 polyfill](https://github.com/zloirock/core-js#ecmascript-string-and-regexp)
- {{jsxref("String.prototype.fontsize()")}}
- {{jsxref("String.prototype.big()")}}