i'm dynamically creating some <div>
elements and then filling their innerhtml
properties with text. i'm trying to set their onclick
event handlers like this:
mydiv.onclick = function() { alert("hello!") };
that i can do. what i would like to do is be able to access the value / innerhtml (new to javascript and dom, so i'm unsure of what term is what i'm looking for) within the newly defined onclick
function. how would i go about accessing the data of mydiv
within the function being defined for its onclick
property? mydiv
will be something simple like:
<div>stackoverflow</div>
any help would be greatly appreciated!
the onclick handler is executed in the context of the element.