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 生日开业蛋糕祝福语简短