Using only pure JavaScript, what is the most efficient way to select all DOM elements that have a certain data-
attribute (let's say data-foo
).
The elements may be different, for example:
<p data-foo="0"></p><br/><h6 data-foo="1"></h6>
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…