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?

lapots
  • 12,553
  • 32
  • 121
  • 242

2 Answers2

4

use ^ selector

var elements = $('[id^="component"]')
Anton
  • 32,245
  • 5
  • 44
  • 54
1

Use wildcards in jQuery selectors:

$('name^=component')
Martin Lantzsch
  • 1,851
  • 15
  • 19