入力フィールドに値 "20"を入力すると "ありがとう"というメッセージが表示されます。入力値にテキストを表示するJavascript関数
$(document).ready(function(){
var money = 20;
/* not sure if this is written correctly, but this is supposed to
check whether the hidden input element value is equal to var money */
if ($("input[id='nominal']").val() == money) {
var h = document.createElement("H1") // Create a <h1> element
var t = document.createTextNode("Thank You"); // Create a text node
h.appendChild(t); // Append the text to <h1>
};
});
私は私が必要なものを満たすために、ひとつのスクリプトを作成しました
が、動作していない:
<form method="post" action="">
<input type="text" id="nominal" value="">
<input type="submit" value="submit">
</form>
はここに私のJSコードです:
は、ここに私のHTMLコードです!どうしましたか?あなたはこの場合changed
には、変更のためのリスニングにイベントを作成する必要が
コードを '$(" nominal ")に置き換えてください。変更(function(){})' – Mohammad
'$( 'body')を追加してください。 ' –
@ThinkDifferentは動作しません –