문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
wiki:html:data-_속성의_값_출력하기 [2020/04/29 18:57] jskim |
wiki:html:data-_속성의_값_출력하기 [2023/01/13 18:44] (현재) |
||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| ===== data-* 속성의 값 출력하기 ===== | ===== data-* 속성의 값 출력하기 ===== | ||
| - | > | + | > |
| <code html> | <code html> | ||
| < | < | ||
| - | < | + | |
| - | < | + | |
| - | <button class=" | + | </ |
| - | TEST BUTTON | + | |
| - | </button> | + | |
| - | </ | + | |
| - | </ | + | |
| </ | </ | ||
| </ | </ | ||
| <code javascript> | <code javascript> | ||
| - | console.log( $(this).data(' | + | console.log( $(this).data(' |
| - | console.log( $(this).data(' | + | console.log( $(this).data(' |
| - | console.log( $(this)[0].dataset.jobcd ); | + | console.log( $(this)[0].dataset.jobcd ); // |
| - | console.log( $(this)[0].dataset.jobCd ); | + | console.log( $(this)[0].dataset.jobCd ); // |
| + | </ | ||
| + | |||
| + | |||
| + | > | ||
| + | <code html> | ||
| + | < | ||
| + | <button class = " | ||
| + | TEST BUTTON | ||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| + | |||
| + | <code javascript> | ||
| + | console.log( $(this).data(' | ||
| + | console.log( $(this).data(' | ||
| + | console.log( $(this)[0].dataset.jobcd ); // | ||
| + | console.log( $(this)[0].dataset.jobCd ); //undefined | ||
| + | </ | ||
| + | * data속성명에 camelCase를 사용할 경우 유의해야 함. | ||
| + | |||