jQuery 实现节点的创建

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'Jquery007.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		
		<script type="text/javascript" src="js/jquery-1.6.1.js"></script>
		<!-- jQuery实现节点的创建 -->
		<script type="text/javascript">
			$(document).ready(function() {
				//获得button对象
				var btn1 = $("#btn1");
				btn1.click(function() {
					var div1 = $("#div1");
					//将div中的html源码清空
					div1.html("");
					var num = Number($("#text1").val());
					var str = "";
					for ( var i = 0; i < num; i++) {
						str += '<input type="text"/></br>';
					}
					div1.append(str);
				});
			});
		</script>
	</head>

	<body>
		<input type="text" id="text1" />
		<input type="button" id="btn1" value="click">
		<div id="div1"></div>
	</body>
</html>
 

你可能感兴趣的:(JavaScript,html,jquery,jsp,cache)