JavaScript doesn't append script <p>I'm using "PHP Form Builder Class" to generate form and submit it with ajax, but i dont think problem is related to "PHP Form Builder Class".</p> <p>I`m loading form and "PHP Form Builder Class" is generating javascript that binds some events to submit action, and jquery-ui button etc.</p> <p>When i submit form and get response from server (html+javascript) then i empty container and load new data - with the same form (to show errors or submit new one). </p> <p>Problem is that second time it wont bind any events to my form.</p> <p>I have removed all events from previous html code, before deleting it and adding new one.</p> <p>So now to the weird part - when i insert new html and js into my container it wont show that particular javascript code that is intended for form. I cant see it in html DOM anywhere when inspecting. I added simple alert(1) in it to check if it will run, and it does, although rest of the code doesnt - and i dont get any errors. So how can this alert run when it doesn't show in dom. I'm appending code with jquery.html()</p> <p>I know its not easy to understand my problem, but i hope someone will</p>