Hi,
I have an ajax script executed using jquery when an input text field is changed using keyup. This part works fine. However, I also want to trigger this same keyup event when the form autoloads with some text in this input text field.
I'm auto-loading the form text field by using php to populate the form from the url (get request).
My HTML code:
<input id="code" name="code" type="text" />
My JS:
$(document).ready(function () {
// doesn't work
// i want to execute the code in the function specified within $('#code').keyup(function () {} below. nothing happens here.
if ($('#code').val() != '') {
$('#code').trigger('keyup');
}
// works fine
$('#code').keyup(function () {
// function code
}
}
Not sure if I'm doing this right. Would appreciate if anyone could help me out on this. Thanks! :)