4-3作业
来源:4-3 编程练习
挪威_
2020-01-23 21:49:16
<!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").focus(function () {
$("span").html("请输入用户名").css({color: "inherit"});
$(this).css({border:"1px solid #dfdddd"});
$("input").blur(function () {
if ($("input").val() == "") {
$("span").html("用户名不能为空").css({color: "red",});
$(this).css({border:"1px solid red"});
}
else {
$("span").html(null);
$(this).css({border:"1px solid green"});
}
})
})
})
</script>
</body>
</html>
1回答
好帮手慕星星
2020-01-29
同学你好,代码是正确的,很棒。继续加油,祝学习愉快!
相似问题