<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function add(){
var option = null
var temp= document.getElementById("select")
option = document.createElement("option")
option.appendChild(document.createTextNode(document.getElementById("textfield").value))
option.vaule = document.getElementById("textfield").value
temp.appendChild(option)
}
</script>
</head>
<body>
<label>
<input type="text" name="textfield" id="textfield" />
</label>
<label>
<input type="submit" name="button" id="button" value="添加" onclick="add()"/>
</label>
<label>
<select name="select" id="select">
<option value="111">111</option>
<option value="222">222</option>
</select>
</label>
</body>
</html>
用js 参考一下这个代码<script>
window.onload=function () {
var Odiv=document.createElement("div")//创建一个div
var Ospan=document.createElement("span") //创建一个span
Odiv.style.cssText="width:200pxheight:200pxbackground:#636363
text-align:centerline-height:220px" //创建div的css样式
//Odiv.id="box" //创建div的id为box
//Odiv.className="Box" //div的class为Box
Odiv.appendChild(Ospan) //在div内创建一个span
document.body.appendChild(Odiv) //在body内创建一个div
}
</script>
<tr><td class="tableleft">标题</td>
<td>
<input name="title" type="text" id="title" style="width:150pxvertical-align:middle" maxlength="40" >
<lable>文件名</lable>
<input name="filename" type="text" id="filename" style="width:150pxvertical-align:middle" maxlength="40" >
<lable>时间</lable>
<input name="time" type="text" id="time" style="width:150pxvertical-align:middle" maxlength="40" onClick="WdatePicker()">
<lable>内容简介</lable>
<input name="content" type="text" id="content" style="width:300pxvertical-align:middle" maxlength="50" >
<input type="button" class="btn btn-success" value="增加" id="addTable" onclick="add_tr(this)"/>
<input type="button" class="btn btn-success" value="删除" id="deleteTable"/>
</td>
</tr>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
function add_tr(obj) {
var tr = $(obj).parent().parent()
tr.after(tr.clone())
}
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)