Post
HTML
<div id="product" data-min="100" data-max="150" data-itemtype="electronics">
컴퓨터
</div>
JS
let item = document.querySelector("#product");
console.log(item.dataset.min);
console.log(item.dataset.max);
console.log(item.dataset.itemtype);
console.log(item.getAttribute("data-min")); // 데이터셋 미지원 브라우저에서는 getAttribute()로 접근해야 함
console.log(item.textContent);
ON BROWSER

'HTML related' 카테고리의 다른 글
| HTML Redirection (0) | 2023.01.21 |
|---|---|
| HTML Examples Favicon Setting (0) | 2023.01.21 |
| HTML Open Graph (0) | 2023.01.19 |
| HTML Examples Dataset (0) | 2023.01.19 |
| HTML Examples Form#Others (0) | 2023.01.19 |