87,993
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>测试</title>
<script type="text/javascript">
window.onload = function () {
var obtn = document.getElementById("btn");
var oTxt = document.getElementById("txt");
obtn.onclick = function () {
alert(obtn.value);
oTxt.value = "修改";
}
}
</script>
</head>
<body>
<input type="text" value="默认的文字" id="txt" />
<input type="button" value="清空" id="btn" />
</body>
</html>