요구 사항 및 코드는 다음과 같습니다.
"이것은 내 코드입니다."
<입력 유형 = "text"id = "price2"value = "333" /> <입력 유형 = "text"id = "trueprice"value = "" />
<script type = "text/javaScript"> document.getElementById ( "price2"). onkeyUp = function () {document.getElementById ( "trueprice"). value = this.value;} </script>질문 : 이제이 페이지를 열면 Trueprice의 값이 기본적으로 비어 있습니다. Trueprice의 기본 개구부는 Price2와 어떻게 동일합니까? (Price2는 동적 가치입니다)
<입력 유형 = "text"id = "trueprice"value = " />는 수정되어 수정할 수 없습니다.
내 간단한 구현 :
<! docType html> <html> <head> <메타 http-equiv = "content-type"content = "text/html; charset = utf-8"> <title> test </title> </head> <body> <입력 유형 = "텍스트"id = "price2"value = "333"onkeyup = "test." id = "trueprice"value = "" /> <script type = "text /javaScript"> var price2 = docum defaultVal;} </script> </body> </html>
효과:
첫 번째 텍스트 상자에 입력 된 내용은 두 번째 텍스트 상자와 동기화 될 수 있습니다.