我在Javascript中新,我只是想改变打印网页上的字值,我已经下一个代码:的JavaScript文件撰写选择选项
<select id="quantity">
<option value="value1">1</option>
<option value="value2">2</option>
</select>
<p id="p1">Change Value </p>
<script>
var x = document.getElementById("quantity");
var y=x.options[x.selectedIndex].value;
document.getElementById("p1").innerHTML=y;
</script>
我想是当选择选项更改时更改书面文字。 谢谢。
了解事件处理:http://www.quirksmode.org/js/introevents.html,http://www.w3.org/wiki/Handling_events_with_JavaScript。并且不要使用'document.write'。 –