急 等 求改造一个简单的JS 本帖最后由 mymhcb 于 2012-05-19 13:54:08 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><body><div id="box"><input type="button" value="+" onclick="javascript:addRemoveItem('add','box');" /><br /><input type="button" value="" id="record"/><br/></div><script type="text/javascript">var maxid = 0;function addRemoveItem(act,target){ var record = document.getElementById("record"); if ((!act || act == 'add') && target){ var $box = typeof(target) != 'object' ? document.getElementById(target) : target; if (!$box) return; var obj = document.createElement('<SPAN>'); var id = "input_" +maxid + "_id"; obj.innerHTML = maxid + " <input type='text' name='input_"+maxid+"' value='' />" + '<input type="button" value="-" onclick="javas'+'cript:addRemoveItem(\'del\',this.parentNode);" /><br />'; $box.appendChild(obj); obj = $box = null; record.value += (maxid == 0?"":",")+id; maxid++; } else if (act == 'del' && target){ if (typeof(target) != 'object') return; target.parentNode.removeChild(target); var idno = window.parseInt(target.childNodes[1].name.split("_")[1]); record.value = record.value.replace((idno == 0?"":",")+"input_"+idno+"_id",""); maxid--; }}</script></body></html> 基于jQuery的插件互相冲突的问题 如何让一个窗口一打开就最大化 而且禁止最小化 涉及JAVASCRIPT的网页怎样传参数? json中属性带点号怎么得到其中的值 关于图片显示的问题?? 怎样把字符串格式化成控件的ID? 如何禁止遨游浏览器的“在新窗口中打开页面连接” 关于jquery $.each方法体内的IF方法只执行一次的问题 调用document.write()为什么会导致表单提交?如何不提交? 如何判断回车字符和TAB字符? javascript滚动代码求帮助。。。 杜圃悟IT清明力荐 75种jquery特效 一键下载 用过挺好的
<body>
<div id="box">
<input type="button" value="+" onclick="javascript:addRemoveItem('add','box');" /><br />
<input type="button" value="" id="record"/><br/>
</div>
<script type="text/javascript">
var maxid = 0;
function addRemoveItem(act,target){
var record = document.getElementById("record");
if ((!act || act == 'add') && target){
var $box = typeof(target) != 'object' ? document.getElementById(target) : target;
if (!$box) return;
var obj = document.createElement('<SPAN>');
var id = "input_" +maxid + "_id";
obj.innerHTML = maxid + " <input type='text' name='input_"+maxid+"' value='' />" + '<input type="button" value="-" onclick="javas'+'cript:addRemoveItem(\'del\',this.parentNode);" /><br />';
$box.appendChild(obj);
obj = $box = null;
record.value += (maxid == 0?"":",")+id;
maxid++;
} else if (act == 'del' && target){
if (typeof(target) != 'object') return;
target.parentNode.removeChild(target);
var idno = window.parseInt(target.childNodes[1].name.split("_")[1]);
record.value = record.value.replace((idno == 0?"":",")+"input_"+idno+"_id","");
maxid--;
}
}
</script>
</body>
</html>