麻烦老师检查
来源:4-3 编程练习
最后的魔法使
2020-05-20 16:49:37
<!DOCTYPE html>
<html lang="en">
<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');
})
.blur(function () {
if ($(this).val() == '') {
$('span').text('用户名不能为空');
$(this).css('border-color', 'red');
} else {
$('span').text('');
$(this).css('border-color', 'green');
}
});
</script>
</body>
</html>
1回答
好帮手慕久久
2020-05-20
同学你好,代码正确,很棒,祝学习愉快!
相似问题