If I create a div programmatically with Tampermonkey:

HTML:

<div onclick="myfunc()"/>

script:

function myfunc() { alert("clicked"); }

then click on the div; myfunc is not called in my script.

How can I get this to work?

(I use TM/jQuery to add the div to a page and I would like to attach some functionality to it. I assume I have to redirect the function call in the HTML to the proper place. I also use GM_ functions so I can't just insert the code directly.)

Edit
Report