형태로 저장하므로 객체 데이터는 저장할 수 없습니다. 제이쿼리에서는 데이터 속성의 기능을 확장하는 인
터페이스를 만들어서 객체도 데이터 속성에 저장할 수 있게 만들었습니다. 여기에 관해서는
1
9
장에서 알아
봅니다.
자바스크립트에서 데이터 속성을 수정하거나 데이터를 추가하는 것도 간단합니다. 예를 들어
giraffe
라는 단어가 들어있는 문단을 하이라이트하되 대소문자를 구분하여 찾으려고 한다면
다음과 같이 데이터 속성을 수정할 수 있을 겁니다.
highlightActions
[
0
].
dataset
.
containing
= "
giraffe
";
highlightActions
[
0
].
dataset
.
caseSensitive
= "
true
";
18.10
이벤트
DOM
API
에는
200
개 가까운 이벤트가 정의되어 있고, 각 브라우저마다 비표준 이벤트를 따
로 만들고 있으므로 이 책에서 이벤트를 모두 설명하는 건 불가능합니다. 책에서는 꼭 알아야
하는 이벤트만 설명하겠습니다. 이해하기 쉬운
click
이벤트부터 시작합시다. 클릭 이벤트를
통해 하이라이트 버튼과
highlightParas
함수를 연결하겠습니다.
const
highlightActions
=
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.