<article
id="electriccars"
data-columns="3"
data-index-number="12314"
data-parent="cars">
...
</article>
data-(변수명) = (value값)
형식으로 html에 data를 등록할 수있다.
var article = document.getElementById('electriccars');
article.dataset.columns // "3"
article.dataset.indexNumber // "12314"
article.dataset.parent // "cars"
데이터를 저장한 element를 가져와서
element.dataset.(변수명) 을 사용하면 저장해 놓은 데이터를 가져올 수 있다.
'JavaScript' 카테고리의 다른 글
(CORS 오류 해결방법) 클라이언트에서 API 가져오기 (0) | 2020.08.23 |
---|---|
(axios 오류) 400 (bad request) axios post (0) | 2020.08.22 |
JavaScript template 작업중 Uncaught 오류 (0) | 2020.08.09 |
원하는 데이터 만들기 위한 고민 (0) | 2020.07.19 |
JavaScript에서 Date 정보 가져오기 (0) | 2020.07.09 |