0

单击更改文本时,我需要在屏幕的另一部分显示我的文本字段值。我怎样才能做到这一点?

<div id="placetextfield">
  <script>
    var textfield = "Enter text on shirt:"; 
    textfield = textfield.bold()
    textfield = textfield.fontsize(5)
    document.write("<p>"  + textfield.fontcolor("#FF6600") + "</p>");
  </script>

  <script type="text/javascript">
    function changeText2(){
      var userInput = document.getElementById('userInput').value;
      document.getElementById('textfield').innerHTML = userInput;
    }
  </script>

  <b id='textfield'></b>
  <input type='text' id='userInput'/>
  <input type='button' onclick='changeText2()'value='Change Text'/>
</div>
4

1 回答 1

0
<script type="text/javascript">
function changeText2(){
    var userInput = document.getElementById('userInput').value;
    document.getElementById('yourId').innerHTML = userInput;
}
</script>
<b id='textfield'></b>
<input type='text' id='userInput'/>
<input type='button' onclick='changeText2()'value='Change Text'/>
于 2013-03-16T00:59:59.567 回答