<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input id="username" onblur="newUsername()" placeholder="输入用户名:">
<script>
function newUsername(){
names=["张三","赵四","王五","李六"]
numb=-1
volidUsername=document.getElementById("username").value;
console.log(volidUsername)
for(i in names){
if(volidUsername==names[i]){
numb=i
break
}
}
if(numb==-1){
alert("用户名不可用")
}else{
alert("用户名可用")
}
console.log(numb)
}
</script>
</body>
</html>
12.js(事件练习)
最新推荐文章于 2022-04-20 20:43:22 发布