<div id="test"></div> <script> test.innerHTML = "<p onclick='say()'>bla bla bla</p>"; function say(){ alert("ok"); } </script>