22 lines
746 B
HTML
22 lines
746 B
HTML
|
<!DOCTYPE html>
|
|||
|
<html lang="en">
|
|||
|
<head>
|
|||
|
<meta charset="UTF-8">
|
|||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|||
|
<title>Document</title>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<input type="text" value="">
|
|||
|
<script>
|
|||
|
// 1.选中目标元素 2. 取出value的值
|
|||
|
// 1.选中目标元素 除了通过id来取之外,其他取出来的值都是一些集合(数组)
|
|||
|
// id具有唯一性 所以通过id来取的结果 就是单个元素
|
|||
|
var info=document.getElementsByTagName("input")
|
|||
|
console.log(info)
|
|||
|
document.write("值为"+info[0].value)
|
|||
|
alert(info[0].value)
|
|||
|
prompt("fdgf")
|
|||
|
</script>
|
|||
|
</body>
|
|||
|
</html>
|