要件とコードは次のとおりです。
「これは私のコードです:」
<input type = "text" id = "price2" value = "333" /> <input type = "text" id = "trueprice" value = "" />
<script type = "text/javascript"> document.getElementById( "price2")。onkeyup = function(){document.getElementById( "trueprice")。value = this.value;} </script>質問:このページを開くと、TruePriceの値はデフォルトで空になります。 TruePriceのデフォルトの開口部は、Price2と同じであることをどのように実現できますか? (Price2は動的な値です)
<input type = "text" id = "trueprice" value = "" />は修正できず、変更できません
私の簡単な実装:
<!doctype html> <html> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"> <title>テスト</ittite> <body> <body> <inputタイプ= "テキスト" id = "price2"値= "333 id = "trueprice" value = ""/> <script type = "text/javascript"> var price2 = document.getElementbyid( "price2")。value; document.getElementbyId( "trueprice")。value = food2; function test(defaultval){document.getelementbyid(defayeprice ")。効果:
最初のテキストボックスに入力されたコンテンツは、2番目のテキストボックスに同期することができます