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();
});
精彩评论