获取文本框的value值
<script type="text/javascript">
window.onload = function () {
document.getElementById("btn01").onclick = function () {
alert(document.getElementById("text01").value)
}
}
</script>
<input type="text" id="text01"/>
<input type="button" value="获取值" id="btn01"/>
设置文本框value值
<script type="text/javascript">
window.onload = function () {
document.getElementById("btn").onclick = function () {
/*var value = document.getElementById("username1").value;
document.getElementById("username2").value = value;*/
document.getElementById("username2").value=document.getElementById("username1").value
}
}
</script>
<input type="text" id="username1">
以下代码主要展示this的用法
<input type="text" onblur="alert(this.value)">