function ABC(obj) {
$("#ID").append('<div onclick="obj.func();">TEST</div>');
}
ABC({func: function() { alert("abc"); } })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="ID"></div>
If you run this function, you will not be able to run obj.func
Why is it not called defined?
How can I solve it?