String.prototype.italics()
Deprecated
Avoid using this feature in new projects. HTML wrapper methods exist only for backwards compatibility. Use DOM APIs to create elements instead. This feature may be a candidate for removal from web standards or browsers.>
Consider using the following features instead: DOM.>
String 값의 italics() 메서드는 문자열을 이탤릭체로 보이게 하는 <i> 요소(<i>str</i>)에 해당 문자열을 집어넣은 문자열을 생성합니다.
참고 :
모든 HTML 래퍼 메서드는 더 이상 사용되지 않으며 호환성 목적으로만 표준화되었습니다. 대신 document.createElement()와 같은 DOM API를 사용하시기 바랍니다.
구문
js
italics()
매개변수
없음.
반환 값
<i> 시작 태그, 그 다음 str 내용, </i> 종료 태그로 이어지는 문자열.
예제
>italics() 사용하기
아래 코드는 HTML 문자열을 생성한 다음 document의 body를 해당 문자열로 대체합니다.
js
const contentString = "Hello, world";
document.body.innerHTML = contentString.italics();
이는 다음과 같은 HTML을 생성합니다.
html
<i>Hello, world</i>
italics()를 사용하여 HTML 텍스트를 직접 작성하는 대신 document.createElement()와 같은 DOM API를 사용해야 합니다. 아래의 예를 참고하세요.
js
const contentString = "Hello, world";
const elem = document.createElement("i");
elem.innerText = contentString;
document.body.appendChild(elem);
명세서
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-string.prototype.italics> |