0

Im trying to find a div with a name and a maximum of 2 digits via jquery.find(); Example: "#progressText1", "#progressText2", ..."#progressText12", etc

This is my code (where closeForm is the form that it has the div elements):

var closeDiv= closeForm.find("#progressText[/^\d{1,2}$/;]"); 

And im getting this error:

Uncaught Error: Syntax error, unrecognized expression: #progressText[/^d{1,2}$/;] 

Can someone help me to make it work?

Victor Elizondo
  • 275
  • 1
  • 4
  • 20

1 Answers1

3

Use the jquery selector "starts with"

// assumes closeForm is a jQuery object already formed.

var closeDiv = closeForm.find('div[id^="progressText"]');
silver
  • 650
  • 4
  • 15