I have an element that has an HTML5 attribute datawithout a value, but only such a key:
<div id="1" data-foo>Foo</div>
If I use datasetas follows:
getElementById("1").dataset.foo
then this will return a null value, and I cannot tell if the element has an attribute data-fooor not. Is there a way to check if an element has an attribute data-fooregardless of whether it has a specified value?
source
share