开发者

Loop through all IDs that begin with XXX

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜