For example, I want all the elements with an ID "hide_" + a value. This function must to return "hide_1" and "hi开发者_如何学JAVAde_30", etc, depending of the elements of the page.
Have a look at dollar-dollar syntax:
$$('a[id^="hide_"]')
should get you anchors whose IDs start with 'hide_'.
Most CSS3 is supported from Prototype 1.5.1 +.
One option is to assign common class to that elements and get them by
var elements = $$('.class');
Pure DOM for general regex:
var all_tags = document.getElementsByTagName("*");
var results = [];
for (var i = all_tags.length-1; i >= 0; -- i)
if (regex.test(all_tags[i].id))
results.push(all_tags[i]);
return results;
精彩评论