有谁知道如何循环遍历所有带有名称的ID
因此,例如,在标记中我可能有 50 个 id,全部以“name_”开头,完整的 ID 将类似于 name_2、name_55、name_25 等。
我想遍历所有这些来获取号码。
不太确定从哪里开始......谢谢!
use the 属性开头为 http://api.jquery.com/attribute-starts-with-selector/选择器
$('[id^=name_]').each(function() {
var number = this.id.split('_').pop();
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)