Die Anforderungen und der Code sind wie folgt:
"Das ist mein Code:"
<Eingabe type = "text" id = "price2" value = "333" /> <Eingabe type = "text" id = "Trueprice" value = "" />
<script type = "text/javaScript"> document.getElementById ("price2"). OnKeyUp = function () {document.getElementById ("Trueprice"). Value = this.Value;} </script>Frage: Wenn Sie diese Seite öffnen, ist der Wert von Trueprice standardmäßig leer. Wie können Sie die Standardöffnung von Trueprice erreichen wie Price2? (Price2 ist ein dynamischer Wert)
<Eingabe type = "text" id = "Trueprice" value = "" /> ist behoben und kann nicht geändert werden
Eine einfache Implementierung von mir:
<! DocType html> <html> <head> <meta http-äquiv = "content-type" content = "text/html; charset = utf-8"> <title> test </title> </head> <body> <Eingabe type = "text" id = "price2" value = "333" auf Key upy ". id = "TruePrice" value = ""/> <script type = "text/javaScript"> var price2 = document.getElementById ("price2"). value; document.getElementById ("TruePrice"). value = price2; function test (defaultval) {documentByIdById ("truPrice>.Wirkung:
Der im erste Textfeld eingegebene Inhalt kann mit dem zweiten Textfeld synchronisiert werden