开发者

Regular Expressions in a jQuery selector

开发者 https://www.devze.com 2023-01-13 16:30 出处:网络
Wo开发者_运维知识库uld it be possible to select using a regular expression in jQuery? Something like

Wo开发者_运维知识库uld it be possible to select using a regular expression in jQuery? Something like

$('input[name=^[a-z]+_[1-9].*]')


There's nothing built in, but you could use the filter() method to achieve the same goal:

$('input').filter(function () { return /^[a-z]+_[1-9].*/.test(this.name); })


You can find a regex selector here (by James Padolsey), called like this in your case:

$('input:regex(name,^[a-z]+_[1-9].*)');
0

精彩评论

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