I have this jQuery function that enables a Search button next to a Search field when there is input:
$('form#search').on('keyup', 'input[type=text]', function(event) {
if ($(this).val().length != 0) {
$(this).next('input[type="submit"]').removeProp("disabled");
} else {
$(this).next('input[type="submit"]').prop("disabled", true);
}
event.preventDefault();
});
It would be nice if this function could run automatically on page load as well, not only on keyup.
How can this be done?
Thanks for any help!
1 Answer