老师看一下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>习题</title>
</head>
<body>
<input type="text" value=""><span></span>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script>
//此处写代码
$(document).ready(function(){
$("input").blur(function(){
if($(this).val()){
$(this).css({"borderColor":"green"})
}else{
$(this).css({"borderColor":"red"})
}
if($(this).val()){
$("span").text("")
}else{
$("span").text("请输入用户名")
}
})
$("input").focus(function(){
if($(this).val()){
$("span").text("")
}else{
$("span").text("请输入用户名")
}
$(this).css({"borderColor":"#ccc"})
})
})
</script>
</body>
</html>


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星