js動(dòng)態(tài)創(chuàng)建標(biāo)簽示例代碼
更新時(shí)間:2014年06月09日 10:20:08 作者:
這篇文章主要以示例的方式為大家介紹下js如何動(dòng)態(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">
這是一個(gè)段落。
</p>
<p id="p2">
這是另一個(gè)段落。
</p>
</div>
<input type="button" id="but" value="添加">
</body>
</html>
相關(guān)文章
原生JS封裝animate運(yùn)動(dòng)框架的實(shí)例
下面小編就為大家?guī)?lái)一篇原生JS封裝animate運(yùn)動(dòng)框架的實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-10-10Rxjs?TakeUntil?操作符內(nèi)容梳理總結(jié)
這篇文章主要介紹了Rxjs?TakeUntil操作符內(nèi)容梳理總結(jié),文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-06-06javascript完整操作Table的增加行,刪除行的列子大全
非常漂亮的js操作table行代碼函數(shù)。比較方便2008-10-10javascript實(shí)現(xiàn)禁止復(fù)制網(wǎng)頁(yè)內(nèi)容匯總
本文給大家匯總介紹了幾種使用javascript和CSS實(shí)現(xiàn)禁止復(fù)制頁(yè)面內(nèi)容的方法,非常的實(shí)用,有需要的小伙伴可以參考下。2015-12-12js實(shí)現(xiàn)select跳轉(zhuǎn)功能代碼
實(shí)現(xiàn)select跳轉(zhuǎn)的方法有很多,本例為大家介紹的是js實(shí)現(xiàn)的,通過(guò)location.href獲取跳轉(zhuǎn)地址,需要的朋友可以看看2014-10-10