Find all elements based on ids using regex on jQuery selector
问题 I've got several elements with unique ids like so: <div id='item-1-top'></div> <div id='item-2-top'></div> <div id='item-3-top'></div> I was hoping that the following would work using jQuery: $("#item-[.]+-top").each(function() { $(this).hide(); }); I do not have a good grasp of regular expressions and I would appreciate some input, as the above appears to be incorrect. 回答1: If you were doing this with regex, the expression would simply be: item-\d-top Where the \d indicates any single digit