I did everything I could to make it happen, but without success.
The problem is that I create an element on runtime then bind a function to the element like the following code:
$(document).ready(function() {
$('.rem').click(function() {
$("body").append('<a id="runtime" href="javascript:void(0);">runtime</a>');
});
$('#runtime').bind('click', func_name());
});
//End of doc
function func_name() {
alert('I got it!');
}
In the HTML code I have a label like below:
<div id="body">
<label class="rem">click me</label>
</div>
My second attempt
$(document).ready(function() {
$('.rem').click(function() {
$("body").append('<a id="runtime" href="javascript:void(0);">runtime</a>');
});
$('#runtime').bind('click',function() {
alert($(this).text());
});
});
//End of doc
HTML code:
<div id="body">
<label class="rem">click me</label>
</div>