String.prototype.small()
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Phương thức small() của các giá trị String tạo ra một chuỗi nhúng chuỗi này vào trong phần tử <small> (<small>str</small>), khiến chuỗi này được hiển thị với font chữ nhỏ.
Note:
Tất cả các phương thức bọc HTML đều đã bị deprecated và chỉ được chuẩn hóa cho mục đích tương thích. Hãy sử dụng DOM APIs như document.createElement() thay thế.
Cú pháp
small()
Tham số
Không có.
Giá trị trả về
Một chuỗi bắt đầu bằng thẻ mở <small>, sau đó là văn bản str, và cuối cùng là thẻ đóng </small>.
Ví dụ
>Sử dụng small()
Đoạn code dưới đây tạo ra một chuỗi HTML rồi thay thế nội dung body của document bằng chuỗi đó:
const contentString = "Hello, world";
document.body.innerHTML = contentString.small();
Đoạn code này sẽ tạo ra HTML sau:
<small>Hello, world</small>
Thay vì sử dụng small() và tạo văn bản HTML trực tiếp, bạn nên sử dụng DOM APIs như document.createElement(). Ví dụ:
const contentString = "Hello, world";
const elem = document.createElement("small");
elem.innerText = contentString;
document.body.appendChild(elem);
Đặc tả
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-string.prototype.small> |