You can combine both selectors in a multiple attribute selector.
$("[id^=AAA_][id$=_BBB]")
It will return all the elements that matches all the specified attribute filters:
[id^=AAA_]
matches elements withid
attribute starting withAAA_
, and[id$=_BBB]
matches elements withid
attribute ending with_BBB
.
Another generic alternatives:
- Using a custom
:regex()
selector, - Using a
.filter()
-based approach.