js动态创建标签示例代码
<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>
<%
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+"://"
+request.getServerName()+":"+request.getServerPort()
+path+"/";
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>MyJSP'createElement.jsp'startingpage</title>
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<metahttp-equiv="description"content="Thisismypage">
<scripttype="text/javascript"
src="<%=request.getContextPath()%>/jquery/jquery-1.7.min.js"></script>
<scripttype="text/javascript">
$(function(){
$("#but").click(function(){
varpara=document.createElement("p");
varnode=document.createTextNode("这是新段落。");
para.appendChild(node);
varelement=document.getElementById("div1");
element.appendChild(para);
})
})
</script>
</head>
<body>
<divid="div1">
<pid="p1">
这是一个段落。
</p>
<pid="p2">
这是另一个段落。
</p>
</div>
<inputtype="button"id="but"value="添加">
</body>
</html>
热门推荐
10 升学了祝福语简短句
11 朋友生闺女简短祝福语
12 除夕祝福语大全简短年轻
13 生日弟弟祝福语 简短独特
14 六一祝福语简短十六字
15 保洁阿姨送来祝福语简短
16 关于水的简短祝福语
17 私房进火祝福语简短
18 新房上梁简短祝福语大全