Hello guys I would like to use querSelectorAll() to select all of my child components. They have the followed name: 'c-lwc-Component', 'c-lwc-Search', 'c-lwc-Product'... I was thinking of using this structure: querSelectorAll('c-lwc-*') but it ain't working.

Is this possible? Am I doing it right? Could someone put an example? Thanks

2 Answers 2


You can try to list them for a single query

const components = this.template.querySelectorAll('c-lwc-Component', 'c-lwc-Search', 'c-lwc-Product');



You can also try this, selects all the elements in the component's template whose class attribute starts with "c-lwc-"

const components = this.template.querySelectorAll('[class^="c-lwc-"]');

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .