Using Prototype to find elements by id and toggle them
Today I needed to toggle the view of some elements on an html page. I was trying to find them by id, as I was generating an id that started with an uppercase n like so "N
function toggle_n() {
// this finds all elements that have an id that begins with N
var a = $$("[id^=N]");
// iterate the array and toggle each id
a.each(function(num) {
Element.toggle(num);
});
}
0 comments