jQuery 文件jquery-1.7.2.js下载地址:https://download.csdn.net/download/weixin_40370904/12692261
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- base标签中的href属性可以让当前页面中的相对路径变为绝对路径 -->
<base href="http://localhost:8080/Web_Ex/">
<style type="text/css">
body {
background-color: yellow
}
</style>
<!-- javaScript编写位置 -->
<script type="text/javascript" src="script/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function(){
//给文本框绑定focus事件
$("#userName").focus(function(){
//将显示错误信息的span标签中的文本置空
$("#msgSpan").text("");
//$("#msgSpan").html("<font color='green'>获得焦点后增加的文字</font>");
});
});
</script>
</head>
<body>
<h1>欢迎来到登录页面</h1><br/>
<form action="Login" method="post">
用户名称:<input type="text" name="userName" id="userName"><span id ="msgSpan"style="color:red">${requestScope.msg}</span><br/>
密 码:<input type="password"
name="password"><br /> <input type="submit" value="登录">
</form>
</body>
</html>