0

I've got several elements on the page. Some of the have name id like this component1,component2 and etc.

How to get all this elements(elements with names which start with component) using jquery?

1

2 Answers 2

4

use ^ selector

var elements = $('[id^="component"]') 
Sign up to request clarification or add additional context in comments.

1 Comment

is there pure javascript equivalent document.getElementBy.... or something? Would be nice
1

Use wildcards in jQuery selectors:

$('name^=component') 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.