-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.md
67 lines (43 loc) · 1.94 KB
/
index.md
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
62
63
64
65
66
67
---
title: String.prototype.bold()
slug: Web/JavaScript/Reference/Global_Objects/String/bold
l10n:
sourceCommit: 5a2cea779777daaff451f21ca3b7f4c28a68de9e
---
{{JSRef}} {{Deprecated_Header}}
{{jsxref("String")}} 값의 **`bold()`** 메서드는 문자열을 굵게 보이게 하는 {{HTMLElement("b")}} 요소(`<b>str</b>`)에 해당 문자열을 집어넣은 문자열을 생성합니다.
> **참고:** 모든 [HTML 래퍼 메서드](/ko/docs/Web/JavaScript/Reference/Global_Objects/String#html_wrapper_methods)는 더 이상 사용되지 않으며 호환성 목적으로만 표준화되었습니다. 대신 [`document.createElement()`](/ko/docs/Web/API/Document_Object_Model)와 같은 [DOM API](/ko/docs/Web/API/Document/createElement)를 사용하시기 바랍니다.
## 구문
```js-nolint
bold()
```
### Parameters
없음.
### 반환 값
`<b>` 시작 태그, 그 다음 `str` 내용, `</b>` 종료 태그로 이어지는 문자열.
## 예제
### bold() 사용하기
아래 코드는 HTML 문자열을 생성한 다음 document의 body를 해당 문자열로 대체합니다.
```js
const contentString = "Hello, world";
document.body.innerHTML = contentString.bold();
```
이는 다음과 같은 HTML을 생성합니다.
```html
<b>Hello, world</b>
```
`bold()`를 사용하여 HTML 텍스트를 직접 작성하는 대신 [`document.createElement()`](/ko/docs/Web/API/Document/createElement)와 같은 DOM API를 사용해야 합니다. 아래의 예를 참고하세요.
```js
const contentString = "Hello, world";
const elem = document.createElement("b");
elem.innerText = contentString;
document.body.appendChild(elem);
```
## 명세서
{{Specifications}}
## 브라우저 호환성
{{Compat}}
## 같이 보기
- [Polyfill of `String.prototype.bold` in `core-js`](https://github.com/zloirock/core-js#ecmascript-string-and-regexp)
- [HTML wrapper methods](/ko/docs/Web/JavaScript/Reference/Global_Objects/String#html_wrapper_methods)
- {{HTMLElement("b")}}