views:

54

answers:

3

For example, I want all the elements with an ID "hide_" + a value. This function must to return "hide_1" and "hide_30", etc, depending of the elements of the page.

+3  A: 

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 +.

karim79
Thanks, is exactly what I need. Thank you very much
Nisanio
A: 

One option is to assign common class to that elements and get them by

var elements = $$('.class');
kodisha
A: 

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;
KennyTM