728x90
dataset 은 사용자 정의 데이터 속성으로 HTMLElement 읽기/쓰기 액세스를 제공한다.
An HTML data-* attribute and its corresponding DOM dataset.property modify their shared name according to where they are read or written:In HTML
The attribute name begins with data-. It can contain only letters, numbers, dashes (-), periods (.), colons (:), and underscores (_). Any ASCII capital letters (A to Z) are converted to lowercase.
The property name of a custom data attribute is the same as the HTML attribute without the data- prefix, and removes single dashes (-) for when to capitalize the property's "camel-cased" name.
속성 설정 후에는 값은 String 이고,
예를 들어 element.dataset.sample = null 이여도 data-sample="null"로 변환된다
제거하려면
delete element.dataset.sample;
728x90
'Web > JavaScript' 카테고리의 다른 글
[ES6] promise, async 와 await (1) | 2023.10.19 |
---|---|
DOMContentLoaded, load, beforeunload, unload 이벤트 (0) | 2023.10.19 |
자주 쓰이는 자바스크립트 코드 함수들 정리 1 (0) | 2023.10.12 |
강의들으면서 정리하기 4 (0) | 2023.09.01 |
강의들으면서 정리하기3 (0) | 2023.08.31 |