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
2010-03-30 16:13:06
Thanks, is exactly what I need. Thank you very much
Nisanio
2010-03-30 16:15:37
A:
One option is to assign common class to that elements and get them by
var elements = $$('.class');
kodisha
2010-03-30 16:15:22
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
2010-03-30 16:16:28