<script type="text/javascript">
function setValue(value){
document.getElementById("test").value=value;
}
</script>
页面代码
<input type="text" id="test"/>
<input type="button" οnclick="setValue('event')" value="测试按钮"/>
效果:点击测试按钮,文本框中值变为event
<script type="text/javascript">
function setValue(value){
document.getElementById("test").value=value;
}
</script>
页面代码
<input type="text" id="test"/>
<input type="button" οnclick="setValue('event')" value="测试按钮"/>
效果:点击测试按钮,文本框中值变为event
转载于:https://www.cnblogs.com/jiangyaqiong/p/3991085.html