I just asked a question here about selecting all id's of the form id_*
where * is any string and id is the id of the element. I got a great working solution:
$("*[id^=" + id + "_]").each(function() {... // id is the element name
I need to take this one step further now:
All of my ids will be of the form: a_b_c ...
where a b and c are arbitrarity strings (that do NOT contain a '_'). So, now rather than selecting all the elems of the form id_*
where * could be a_b_c ...
I need only to select 1 level deep: i.e. all elems of the form id_a
. So in other words it stops at the next '_'. Is this possible?
As an example:
If my id is: first
And there exist id's: first_second
, first_second_third
It will select only first_second