I have a legacy PHP application which uses brackets in it’s naming of form elements e.g.
<select name="samplegroup[776]" id="samplegroup[776]">
<option value="1">1</option>
<option value="2" selected >2</option>
<option value="3">3</option>
</select>
<select name="samplegroup[883]" id="samplegroup[883]">
<option value="1">1</option>
<option value="2" selected >2</option>
<option value="3">3</option>
</select>
How can I match selects which have samplegroup followed by a number in brackets with jQuery? E.g. $("what_do_i_write_here")?
Using the
attributeStartsWithselector:It probably doesn’t matter that this is ignoring the number in square brackets part, unless you happen to also have other
selectelements that have anamestarting withsamplegroup.http://jsfiddle.net/PbSVY/