document.observe('dom:loaded' , function(){
$$('.menu_button').each(function(s) {
s.observe('click', function(){
$('nav_bg').toggle();
});
});
});
I think this will work. I dont think you have to be explicit about the display:block, Im not sure how prototype decides which display it decides to give an object on toggle, but its usually pretty good about picking the right one.
If you do need to be explicit
document.observe('dom:loaded' , function(){
$$('.menu_button').each(function(s) {
s.observe('click', function(){
if ( $('nav_bg').getStyle('display') === 'block')
$('nav_bg').setStyle({'display' : 'none'});
else
$('nav_bg').setStyle({'display' : 'block'});
});
});
});
Not very graceful, and Im sure prototype has a better way of doing it. But Im not a master and this will get it done.