老师这样可以么
来源:4-3 编程练习
慕丝329460
2019-04-11 23:07:53
$('input').focus(function(){
$(this).css('borderColor','blue');
$('span').text('请输入用户名');
});
$('input').blur(function(){
if($(this).val()==""){
$(this).css('borderColor','red');
$('span').text('用户名不能为空');
}else{
$(this).css('borderColor','green');
$('span').text('');
}
});
1回答
好帮手慕码
2019-04-12
同学你好!
经过测试,代码效果实现很好~
代码可优化:按照效果图 建议给边框设置1px的宽度,
如果帮助到了你欢迎采纳,祝学习愉快~
相似问题