Can jQuery or JavaScript be used with a regex to select multiple elements with similar id?
I have the following paragraphs:
Yes it can, you can combine the attribute starts with and the attribute ends with selector
$('[id^="item"][id$="2"]').html("D");
FIDDLE (and you have to enable jQuery in the fiddle)
you can't use regex to match the numbers in between though, for that you'd need filter()
$('[id^="item"]').filter(function() {
return this.id.match(/item\d+_2/);
}).html("D");