Suppose I have below codes written with jquery:
<script>
$(function () {
$("#btn1").click(function () { alert("OK"); });
});
</script>
<body>
<input type="button" value="input" id="btn1" /><label id="lbl"></label><br />
</body>
I need get the function of btn1. The pseudo code as follows:
var f=Get_function_of_btn1("#btn1").
Then, when I call f(), it alerts "OK".
How to implement it?
BTW, can jquery print the function as string? like below:
console.log(f);
then it will print :
function () { alert("OK"); }