HTMLAnchorElement: thuộc tính text
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính text của giao diện HTMLAnchorElement đại diện cho văn bản bên trong phần tử. Thuộc tính này đại diện cho cùng thông tin như Node.textContent.
Giá trị
Một chuỗi.
Ví dụ
html
<a id="exampleLink" href="https://example.com">Ví dụ liên kết</a>
<p class="text"></p>
css
#exampleLink {
font-size: 1.5rem;
}
js
const anchorElement = document.getElementById("exampleLink");
const pTag = document.querySelector(".text");
pTag.textContent = `Thuộc tính text: ${anchorElement.text}`;
Kết quả
Đặc tả kỹ thuật
| Specification |
|---|
| HTML> # dom-a-text> |
Trình duyệt hỗ trợ
Xem thêm
- Thuộc tính
HTMLScriptElement.text - Thuộc tính
HTMLOptionElement.text