单击更改文本时,我需要在屏幕的另一部分显示我的文本字段值。我怎么能这样做?
<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>
答案 0 :(得分: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'/>