$(cells[0]).toggle(); should do the trick. That's because "getElementsByTagName" returns NodeList of unextended elements [1]
You could also use $$('#test tr:first-child td:first-child') - that should give the same result Best, kangax [1] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1938918D On Mar 25, 10:34 am, CO2 <[EMAIL PROTECTED]> wrote: > I just ran another test on a basic page: > > <html> > <head> > <script language='JavaScript' src='prototype.js'></script> > <script> > function change2() > { > $('cell').toggle(); > } > > function change() > { > var tbl = $('test'); > var rows = tbl.getElementsByTagName('tr'); > var cells = rows[0].getElementsByTagName('td'); > cells[0].toggle(); > } > </script> > </head> > <body> > <table id="test"> > <tr><td id="cell">This is weird.</td></tr> > </table> > <input type="button" onClick="change()" value="Button 1" /> > <input type="button" onClick="change2()" value="Button 2" /> > </body> > </html> > > When I click button 1 I get the error. Button 2 works. However when I > click button 1 after having toggled with button 2 before it even works > with button 1. > Is there something I can do about it? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---