Dynamically generate table and then add td based upon some condition?

Dynamically generate table and then add td based upon some condition?

I have javascript method where based on condition I add table and tr. Then based on other condition I call another javascript method where I want to add new td each time.

I looked at this link http://forum.jquery.com/topic/jquery-insert-td-before-previous-td

But here td is added before to any other td and I want to add on some condition after previous td. If there is any jquery way plz let me know.