mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
30 lines
619 B
HTML
30 lines
619 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<body>
|
|
|
|
<div id="a" data-a="1" data-b="abc" data-cd="123"></div>
|
|
|
|
<button onclick="myFunction()">Try it</button>
|
|
|
|
<p id="demo"></p>
|
|
|
|
<script>
|
|
function myFunction() {
|
|
var div = document.getElementById('a');
|
|
console.assert(div.dataset.b === 'abc', 'abc');
|
|
div.dataset.b = '123';
|
|
console.assert(div.dataset.b === '123', '123');
|
|
console.assert(div.dataset.abc === undefined, 'undefined');
|
|
|
|
delete(div.dataset.b);
|
|
console.assert(div.dataset.b === undefined, 'undefined because deleted');
|
|
}
|
|
|
|
console.error('element.dataset.html');
|
|
myFunction();
|
|
console.exit();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|