请老师检查,谢谢

来源:4-3 编程练习

Ev4ngel

2019-04-09 20:33:28

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>jQuery中input获得和失去焦点练习</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({"borderColor":""});
})
$("input").blur(function(){
if($(this).val()!=""){
$(this).css({"borderColor":"green"});
$("span").text("");
}else{
$(this).css({"borderColor":"red"});
$("span").text("用户名不能为空");
}
})
</script>
</body>

</html>


写回答

1回答

好帮手慕慕子

2019-04-10

同学你好,效果实现的是可以的,继续加油!

欢迎采纳,祝学习愉快~~~

0

0 学习 · 36712 问题

查看课程