Here are four different ways to approach the problem:
Option #1: You can put them all into one selector:
$("#element_1_value, #element_2_value, #element_3_value, #element_4_value, #element_5_value").click(function() {
// your code here
})
Option #2: Even better would be to assign a common class to all of them:
<div id="element_1_value" class="valueCommon">
<div id="element_2_value" class="valueCommon">
...
And, then use this:
$(".valueCommon").click(function() {
// your code here
})
Option #3: It's also possible to write selectors for what id's that start and end with a given string, but I wouldn't recommend this because it requires the selector engine to examine every single object in the page that has an id attribute which isn't the fastest way of doing things:
$("[id^='element_']").filter("[id$='_value']").click(function() {
// your code here
})
Option #4: I'm not aware of any built-in jQuery support for regex matches in selectors. You can use a filter function where any arbitrary javascript could examine and object to decide if it matched of not, but the only way to use that with a regex would require creating a jQuery object of all objects in the page with an id and then running the filter on each one. That could work, but is certainly not the most effective way to do things. Using a common class allows the browser to optimize your queries much more than the regex filter.
A regex match would look like this:
$("[id]").filter(function() {
return(this.id.match(/element_\d+_value/) != null);
});
This creates a jQuery object of all objects in the page that contain an id attribute and then compares each one to the regex, removing any element that doesn't match. As I've said earlier, I would not recommend this for performance reasons.