I have a page that generates a form dynamically
using append('texto html');
These inputs that I generate after loading the page completely, I can not by them invoke functions js created in the ready of the page, that is, before the inputs exist.
ex: I create a named form and cpf and the save button using append.
In my script there already exists a salvar(){}
method and at the time I create the button in onclick, I call the save () function, but it does not work. I think because the input was being created after the page load. Can you do something to fix this?
<script type='text/javascript'>
$( document ).ready(function() {
$('#confirm_edit').click(function(){
$('#form_execucao').append('<br class=\"campos bts\" /><br class=\"campos bts\" />');
$('#form_execucao').append('<label id=\"bt_print\" name=\"bt_print\" onclick=\"pt()\" style=\"margin-left:5px; height:30px; font: normal 13px Verdana, Arial, Times;\" for=\"salvar\" class=\"btn btn-primary campos bts\"><i class=\"glyphicon glyphicon-print\"></i> Imprimir</label>');
$('#form_execucao').append('<label id=\"bt_salvar\" name=\"bt_salvar\" onclick=\"sv()\" style=\"margin-left:10px; height:30px; font: normal 13px Verdana, Arial, Times;\" for=\"salvar\" class=\"btn btn-info campos bts\"><i class=\"glyphicon glyphicon-floppy-disk\"></i> Salvar</label>');
});
function pt(){
alert('imprimindo');
}
function sv(){
alert('salvando');
}
});
</script>