I am having a bit of trouble on how to apply jquery event helpers on selectors that have been appendTo. I have this code:
$('<input/>').attr({ id: 'submitbtn', type: 'submit', value: 'Click me' }).appendTo('form');
Now, when I try to use click function on this appended submit button nothing happens
$('input#submitbtn').click(function() { // code here });
While it works fine if this element was pure html. How can I make this work? Any help appreciated.
Thanks in advance!