mirror of
https://github.com/atapas/html-tips-tricks.git
synced 2024-11-16 00:38:26 +01:00
Corrected data attribute
This commit is contained in:
parent
a80e245253
commit
01d59620b9
1 changed files with 5 additions and 2 deletions
|
@ -12,7 +12,7 @@
|
|||
<script>
|
||||
function reveal() {
|
||||
let dataDiv = document.getElementById('data-attr');
|
||||
let value = dataDiv.getAttribute('data-custom-attr');
|
||||
let value = dataDiv.dataset['customAttr'];
|
||||
document.getElementById('msg').innerHTML = `<mark>${value}</mark>`;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,10 @@
|
|||
<img src="../home.svg" alt="home" />
|
||||
</a>
|
||||
<h2> Know data attribute </h2>
|
||||
<div class="data-attribute" id="data-attr" data-custom-attr="You are just Awesome!"> I have a hidden secret!
|
||||
<div
|
||||
class="data-attribute"
|
||||
id="data-attr"
|
||||
data-custom-attr="You are just Awesome!"> I have a hidden secret!
|
||||
</div>
|
||||
<button onclick="reveal()">Reveal</button>
|
||||
|
||||
|
|
Loading…
Reference in a new issue