开发者

Regular Expressions in a jQuery selector

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜