任何人对这个jQuery有所帮助我试图启动我无法使正则表达式工作
cj("input[id='PRE_TEXT_'(.*)'_POST_TEXT']").hide();
答案 0 :(得分:3)
你不能在jQuery选择器中使用正则表达式。使用过滤功能:
cj("input").filter(function() {
if (/^PRE_TEXT_(.*)_POST_TEXT$/.test(cj(this).prop("id"))) {
return true;
}
return false;
}).hide();
答案 1 :(得分:2)
您不能使用正则表达式,但您应该能够使用startwith和endswith。
cj("input[id^='PRE_TEXT_'][id$='_POST_TEXT']").hide();