Desired output in HTML:
<input onclick="someFunction(this)"/>
Attempt:
var input = $("<input/>");
input.attr("onclick", "someFunction(this)");
$("#body").append(input)
Result:
<input onclick="[object Object]"/>
I have tried using:
input.click({param: "this"}, someFunction);
I have also tried replacing "this" with "input". No luck.
jQuery is not a requirement, however I need this done dynamically. The above is just a sample, the actual object has more attributes.
input.on('click', e => someFunction(e.target))Why does it matter whether you render an attribute or create the listener in memory?