开发者

Loop through all IDs that begin with XXX

开发者 https://www.devze.com 2023-01-14 10:33 出处:网络
Would anyone know 开发者_运维知识库how to loop through all ID\'s that being with name_ So, for example, within the markup I may have 50 id\'s that all start with \"name_\", the full ID would be like

Would anyone know 开发者_运维知识库how to loop through all ID's that being with name_

So, for example, within the markup I may have 50 id's that all start with "name_", the full ID would be like name_2, name_55, name_25, etc.

I'd like to loop through all of these getting the number.

Not really sure where to begin....... thank you!


use the attribute starts with selector

$('[id^=name_]').each(function() {
    var number = this.id.split('_').pop();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号