3节点的集合
2025年5月1日小于 1 分钟
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>节点的集合</title>
</head>
<body>
<form action="">
用户名: <input type="text" name='uname'>
邮箱: <input type="text" name='email'>
<select name=" " id="">
<option value=" ">请选择</option>
</select>
</form>
<form action="">
手机号: <input type="text" name='phone'>
男:<input type="radio" name='sex'>
女:<input type="radio" name='sex'>
</form>
<form action="">
密码: <input type="text" name='pass'>
</form>
<a href="">百度</a>
<a href="">淘宝</a>
<a href="">腾讯</a>
<img src="./sunli/1.jpg" alt="" width='400px' height='300'>
<img src="./sunli/2.jpg" alt="" width='400px' height='300'>
<img src="./sunli/3.jpg" alt="" width='400px' height='300'>
<script type="text/javascript">
//获取form集合
var forms = document.forms;
// console.log(forms);
//elemets
var ipus = forms[0].elements;
// console.log(ipus);
/*ipus[0].onfocus = function()
{
alert('123456');
}*/
//name属性名对应的值
// var names = forms[1].phone;
var sexs = forms[1].sex;
// console.log(sexs);
/*names.onfocus = function()
{
alert('asdfg');
}*/
//获取a链接集合 返回的结果是一个数组
var as = document.links
// console.log(as);
for (var i = 0; i < as.length; i++) {
as[i].onclick = function()
{
location.href='';
return false;
}
};
//获取所有的img
var imgs = document.images;
setInterval(function(){
// console.log(imgs);
for (var i = 0; i < imgs.length; i++) {
/*imgs[i].onclick = function()
{
this.src = './sunli/5.jpg';
}*/
imgs[i].src = './sunli/'+rand(1,13)+'.jpg';
};
},1000)
function rand(m,n){
return Math.ceil(Math.random()*(n-m+1))+(m-1);
}
</script>
</body>
</html>