私はこの問題にしばらく取り組んできましたが、私が思いついたすべての解決策は「ほぼ機能します」。理想的には、入力時に入力値を変数に保存したいので、入力値が変数に保存される前にコマンドを実行する必要はありません。その解決策が見つからなかったので、入力がフォーカスを失ったらすぐに変更するように取り組んできました。.focusout、.change、および.blurを試しましたが、入力がフォーカスを失った瞬間に実際に変更するものはありません。
//This will save the input value into the variable formInput
var formInput = $("#someForm input[type=text]").val();
//This successfully changes the value of formInput, but only after performing
//another command, such as clicking go or pressing enter.
//Tab does not count to the input "losing focus"
$("#someForm input[type=text]").focusout(function() {
$(this).val() = formInput.val();
});
// Same as focusout, as well as blur.
$("#someForm input[type=text]").change(function() {
$(this).val() = formInput.val();
});
//Nope.
$("#someForm input[type=text]").keyup(function() {
formInput = $("this").val();
});