循环浏览以XXX开头的所有ID [英] Loop through all IDs that begin with XXX
本文介绍了循环浏览以XXX开头的所有ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人会知道如何遍历具有name_的所有ID.
Would anyone know how to loop through all ID's that being with name_
例如,在标记中,我可能有50个以"name_"开头的id,完整的ID类似于name_2,name_55,name_25等.
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!
推荐答案
使用属性始于选择器
$('[id^=name_]').each(function() {
var number = this.id.split('_').pop();
});
这篇关于循环浏览以XXX开头的所有ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文