Skip to content

Instantly share code, notes, and snippets.

>>> var ds = document.getElementById('gallery-image1').dataset;
>>> ds.authorName;
"Dave"
>>> ds.location;
"Austin, TX"
>>> ds.date;
"August 14th, 2011"
>>> var ds = document.getElementById('gallery-image1').dataset;
>>> ds.authorName = 'David';
"David"
>>> var ds = document.getElementById('gallery-image1').dataset;
>>> delete ds.authorName;
true
>>> document.getElementById('gallery-image1').dataset.authorName;
undefined
div[data-author-name="Dave"] {
background-color: blue;
}
>>> var clNode = document.getElementById('clExample');
>>> clNode.classList
// ['red', 'green', 'bold']
>>> clNode.classList.length
3
>>> clNode.classList.remove('bold')
// Now the classList is ['red', 'green']
<div id="clExample" class="red green bold"></div>