jQuery find all id's that begin with a defined string and end in a number

雨燕双飞 提交于 2019-12-05 15:33:19

Unfortunately, there is no regular expression selector.

You could use the attribute-starts-with selector, then filter the results and check for numeric endings using search()

Eg

var divs = jqueryElement.find('[id^="divIdWithIterator"]').filter(function(index){
    return this.id.search(/\d$/) != -1;
});

Following: http://api.jquery.com/attribute-starts-with-selector/

To find the elements whose id begin with "divIdWithIterator":

$('input[id^="divIdWithIterator"]')

And then avoid to have other elements that begin with "divIdWithIterator" and you don't want to select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!