I have an input the with a live class "btnForget", I tried this code
$("document").on('keydown', '.btnForget', function() {
alert("keydown...");
});
But it doesn't work if the class is not there from the beginning.
I have an input the with a live class "btnForget", I tried this code
$("document").on('keydown', '.btnForget', function() {
alert("keydown...");
});
But it doesn't work if the class is not there from the beginning.
You should not use quotes with document
<!-- works -->
$(document).on('keydown', '.btnForget', function() {
alert("without");
});
<!-- does not work -->
$("document").on('keydown', '.btnForget', function() {
alert("with");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button type="button" class="btnForget">Click</button>