O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Injecting a table into the HTML DOM

Tuning in from the previous two recipes? Great! The superhero saga is about to be tabled, and you are just in time for today's exciting episode where we really get loopy on our heros!

How to do it...

We will create a table in memory and for each hero, build a tr with a td in it and finally inject the HTML table into the DOM.

<h1>World's Coolest Superheroes</h1> </div> <form action="javascript:" method="get" id="my_form"> <input id="submit" type="button" value="Add a TABLE"/> </form> <script type="text/javascript"> var other_heroes = ['Spider-Man', 'Iron Man', 'Hulk', 'Captain America', 'Daredevil', 'Wolverine', 'Squirrel Girl']; var next = 0; var total = other_heroes.length; $('submit').addEvent('click', function() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required