Skip to content

Commit 01d5962

Browse files
committed
Corrected data attribute
1 parent a80e245 commit 01d5962

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

data-attribute/index.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<script>
1313
function reveal() {
1414
let dataDiv = document.getElementById('data-attr');
15-
let value = dataDiv.getAttribute('data-custom-attr');
15+
let value = dataDiv.dataset['customAttr'];
1616
document.getElementById('msg').innerHTML = `<mark>${value}</mark>`;
1717
}
1818

@@ -25,7 +25,10 @@
2525
<img src="../home.svg" alt="home" />
2626
</a>
2727
<h2> Know data attribute </h2>
28-
<div class="data-attribute" id="data-attr" data-custom-attr="You are just Awesome!"> I have a hidden secret!
28+
<div
29+
class="data-attribute"
30+
id="data-attr"
31+
data-custom-attr="You are just Awesome!"> I have a hidden secret!
2932
</div>
3033
<button onclick="reveal()">Reveal</button>
3134

0 commit comments

Comments
 (0)