Find an element that has an attribute matching a pattern

Viewed 329

How to find all elements that have attributes that match pattern data-foo-bar-*, e.g.

<div data-foo-bar-id="" />

Using document.querySelectorAll with foo-bar-* pattern gives error:

Uncaught SyntaxError: Failed to execute 'querySelectorAll' on 'Document': '[data-foo-bar-*]' is not a valid selector.

1 Answers
Related