<!DOCTYPE html>
<html lang="">
<head>
<meta charset="gb2312">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title>123</title>
<script src="Scripts/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var spotMax = 30
if($('div.spot').size() >= spotMax) {$(obj).hide()}
$("input#add").click(function(){ addSpot(this, spotMax)
})
})
function addSpot(obj, sm) {
$('div#spots').append(
'<div>' +
'<span><input name="shengfen" type="text" /></span>'+
'<span><input name="diqu" type="text" /></span>'+
'<input type="button" class="remove spot01" value="删除行" /></div>')
.find("input.remove").click(function(){
$(this).parent().remove()
$('input#add').show()
})
if($('div.spot').size() >= sm) {$(obj).hide()}
}
</script>
</head>
<body>
<span><input name="shengfen" type="text" /></span>
<span><input name="diqu" type="text" /></span>
<input type="submit" id="add" name="Submit" value="添加行" >
<div>
<form method="post" name="asdf" id="asdf"><div id="spots"></div></form>
</div>
</body>
</html>
效果这样(样式再自己调)
要加jQuery插件进去
不懂再追问
那个代码中的这段<div align="center"><div id=AdRotator></div><input id="second"><button onClick="adRotator.set(getRef('second').value)">set time</button></div>
这是显示的层 把它放到TD里面就可以了
原先代码中的这段要删除
不要等待提示就把这段代码
getRef(_o).innerHTML="total images " + _p.length + ", loading picture " + _c + ' ' + _i.readyState + "..."
_timeout=window.setTimeout(adRotator.load,10)
}
}
else
{
getRef(_o).innerHTML="total images " + _p.length + ", loading picture " + _c + ' ' + _i.readyState + "..."
_timeout=window.setTimeout(adRotator.load,10)
改成:
getRef(_o).innerHTML=""
_timeout=window.setTimeout(adRotator.load,10)
}
}
else
{
getRef(_o).innerHTML=""
_timeout=window.setTimeout(adRotator.load,10)
就可以了
其实就是把getRef(_o).innerHTML=""的值给空不给他赋值,统计还在工作 但是不会显示了。
思路:
添加:往页面类型是button的input 标签
删除:通过input标签查找所有添加的按钮,移除其中一个
代码示例:
<script>function add(){
var buttons = document.getElementById('buttons')
buttons.innerHTML += ("<input type='button' value='新1'/>")
}
function del(){
var buttons = document.getElementById('buttons')
var inputs =buttons.getElementsByTagName('input')
if(inputs.length>0){
inputs[0].remove()
}
}
</script>
</head>
<body>
<div id='buttons'>
</div>
<input type='button' value='添加' onclick='add()'/>
<input type='button' value='删除' onclick='del()'/>
</body>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)