1

There are some elements whose class have a pattern of:

view-???-panel

Like:

<iframe name="view-111-panel"></iframe>
<iframe name="view-112-panel"></iframe>

I want to use document.querySelectorAll to find them. I know to how to query with "startsWith" and "endsWith":

document.querySelectorAll('iframe[name^="view-"]')
document.querySelectorAll('iframe[name$="-panel"]')

But I can't find a way to combine them together.

Is it possible to do it all by querySelectorAll?

Freewind
  • 193,756
  • 157
  • 432
  • 708

1 Answers1

2

You CAN combine selectors document.querySelectorAll('iframe[name^="view-"][name$="-panel"]') https://api.jquery.com/multiple-attribute-selector/ (vanilla JS is the same)

Smollet777
  • 1,618
  • 1
  • 16
  • 15