how to get element by attribute value in javascript

JavaScript
document.querySelectorAll('[data-foo="value"]');
Source

Also in JavaScript: