How can I insert custom html code inside a div dynamically?

How can I insert custom html code inside a div dynamically?