js動態(tài)創(chuàng)建標(biāo)簽示例代碼
更新時間:2014年06月09日 10:20:08 作者:
這篇文章主要以示例的方式為大家介紹下js如何動態(tài)創(chuàng)建標(biāo)簽,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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 'createElement.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="<%=request.getContextPath()%>/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript">
$(function() {
$("#but").click(function() {
var para = document.createElement("p");
var node = document.createTextNode("這是新段落。");
para.appendChild(node);
var element = document.getElementById("div1");
element.appendChild(para);
})
})
</script>
</head>
<body>
<div id="div1">
<p id="p1">
這是一個段落。
</p>
<p id="p2">
這是另一個段落。
</p>
</div>
<input type="button" id="but" value="添加">
</body>
</html>
相關(guān)文章
Rxjs?TakeUntil?操作符內(nèi)容梳理總結(jié)
這篇文章主要介紹了Rxjs?TakeUntil操作符內(nèi)容梳理總結(jié),文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-06-06javascript完整操作Table的增加行,刪除行的列子大全
非常漂亮的js操作table行代碼函數(shù)。比較方便2008-10-10javascript實現(xiàn)禁止復(fù)制網(wǎng)頁內(nèi)容匯總
本文給大家匯總介紹了幾種使用javascript和CSS實現(xiàn)禁止復(fù)制頁面內(nèi)容的方法,非常的實用,有需要的小伙伴可以參考下。2015-12-12