老师,请检查,谢谢
来源:4-3 编程练习
Moomin6
2019-06-04 00:03:44
<!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>
//此处写代码
$('input').focus(function(){
$('span').text("请输入用户名");
$(this).css({'border-color':'blue'});
})
$('input').blur(function(){
if($('input').val() == ""){
$('span').text("用户名不能为空");
$(this).css({'border-color':'red'});
}else{
$('span').text("");
$(this).css({'border-color':'green'});
}
})
</script>
</body></html>
1回答
你好,实现效果很棒!
祝学习愉快!
相似问题