How to select an element using data attribute in JavaScript?

Consider, we have html elements with data attributes. Now, we need to select the above elements by data attribute in JavaScript. To select the single element, we need to use document.querySelector () method by passing a [data-attribute = ‘value’] as an argument.
For More Information Please Refer:

You May Also Like to Read: