一、文本框
代码示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input id="name" />
<script>
document.getElementById("name").focus();//获取id为name的焦点
function t1(){
var element = document.getElementById("name");
console.log(element.value);
element.value="Kate";
element.readOnly=true;//只读
/*element.disabled=true;//不能被编辑*/
}
</script>
<input type="button" name="name1" id="name1" value="测试" οnclick="t1()"
</body>
</html>
二、密码框
代码示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="passw