How can I get the id
attribute of a dynamically generated element when you don't know it's id
? I am wanting to setup some eventListener
s for about 2000 Checkbox's on a page.
I know I could call a function from within the element:
<input type="checkbox" id="{databaseResult.Value}" onclick="someFunction(this)" />
But I'm not allowed to use JavaScript, or references to it in my HTML. Pure JavaScript (or a language that compiles to it) is my only option.
The code I already have for some elements where I do know the id
, is:
var tb = <HTMLInputElement>document.getElementById("tbox");
if(tb.addEventListener("", function (e) {
sayHello(tb.value);
}, false));