One of my friends had a doubt and she had mailed me this.
I replied to her and at the same time thought that it would be useful to my blog readers as well.
For people, who think that this is complicated, there are some nice ajax libraries out there like prototype and script.aculo.us. You can use their functions and all you would need to do there is to set a boolean variable called evalScripts to true. Many popular sites like Digg and Tezaa use these libraries.
Let me know if this helped. If you found a better solution, let me know too.