Reputation: 31
Anyone help with this jQuery I'm trying to pull off I can't get the regex to work
cj("input[id='PRE_TEXT_'(.*)'_POST_TEXT']").hide();
Upvotes: 1
Views: 378
Reputation: 78630
You can't use regex, but you should be able to use startswith and endswith.
cj("input[id^='PRE_TEXT_'][id$='_POST_TEXT']").hide();
Upvotes: 2
Reputation: 9202
You can't use regex in jQuery selectors. Use the filter function:
cj("input").filter(function() {
if (/^PRE_TEXT_(.*)_POST_TEXT$/.test(cj(this).prop("id"))) {
return true;
}
return false;
}).hide();
Upvotes: 3