文件名:b.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.Connection,java.sql.PreparedStatement,java.sql.DriverManager,java.sql.ResultSet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="jquery-confirm-master/dist/jquery-confirm.min.js"></script>
<link rel="stylesheet" href="jquery-confirm-master/dist/jquery-confirm.min.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Test - b.jsp</title>
</head>
<body>
<form action="b.jsp">
<table border="1">
<tr>
<td>Text:</td>
<td><input type="text" name="myText" id="myText" value=""></td>
<td><input type="Submit" value="Click to Submit"></td>
</tr>
</table>
</form>
<br>
<%
String myText = request.getParameter("myText");
if (myText == null) {
// myText is null when the page is first requested,
// so do nothing
} else {
if (myText.length() == 0) {
// There was a querystring like ?myText=
// but no text, so myText is not null, but
// a zero length string instead.
%>
<b>myText is empty</b>
<% } else {%>
<b>myText is <%= myText%></b>
<%
}
}
%>
<input type="button" id="alert" value="alert me" onclick="bn()">
<script>
function bn() {
$.alert({
title: 'Alert!',
content: 'Simple alert!',
});
}
</script>
</body>
</html>
在上面的代码中,我创建了单独的按钮“Alert”来显示警报框(使用jquery插件),但是如果我想在jquery警报框中显示在text box id=myText中输入文本的警报框,该怎么办。