Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
テキストボックスに数値を入力し、入力後、送信せずにすぐにJavaScript変数に代入したい
したがって、アイデアは数値を入力することです var x =その数値を即座に
ここにhtmlがあります
<form id="tools"> <input type="text" id"stk"/> </form>
今、javascriptは何ですか?:D
イベント(onKeyUp)のハンドラーを割り当てることを実現できます...そしてそのハンドラーは変数に値を割り当てる必要があります。純粋な JavaScript の代わりに jQuery を使用することをお勧めします。
jQuery を使用すると、次のようになります。
var x = 0; $('#textbox-name').onkeypress(function({ x = $(this).attr('value'); }));
構文が間違っていたら申し訳ありませんが、それが主なアイデアです。