<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div>
<input type="text" name="" id="username" value="">
<span id="span1" style="display:none"></span>
</div>
<script src="script/jQuery-1.7.1js"></script><!-- 引入jQuery -->
<script src="/javascripts/application.js" type="text/javascript" charset="utf-8" async defer>
$("#username").blur(function() {
if($("#username").val() == ''){
$("#span1").show().text("请输入用户名!");
}else{
$("#span1").hide();
}
});
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div>
<input type="text" name="" id="username" value="">
<span id="span1" style="display:none"></span>
</div>
<script src="script/jQuery-1.7.1js"></script><!-- 引入jQuery -->
<script src="/javascripts/application.js" type="text/javascript" charset="utf-8" async defer>
$("#username").blur(function() {
if($("#username").val() == ''){
$("#span1").show().text("请输入用户名!");
}else{
$("#span1").hide();
}
});
</script>
</body>
</html>