I am loading Javascript on my HTML page with Ids (div data-x="")(the right way) not contaminating HTML with Javascript like onclick etc. .
…after retrieving/loading with Javascript (a dynamic content inside the div tag), I can not use the id’s for Javascript anymore (inside the loaded content, because JS on ready state has been already loaded and the content was generated later), so I am using onclick now inside the “later loaded content”.
Is this the right approach to use onclick='func1();' or not, is there any other way at all.
Do you mean like this, added to the dynamic content(that is loaded after the main page), once loading the content you can also activate this JavaScript aElistener (in your JavaScript file):
Note, the “Point”: You need to call the function you would like to use inside the other function that loaded(after loading) the new content. It’s quite logical but, nah missed it in this thread.