1,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"><br>
2,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"><br>
3,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"><br>
<input type=button value=delete onclick="d()" UNSELECTABLE=true>
<script>
var n = 0
function f(u)
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file") o[i].setAttribute("ok","")
u.setAttribute("ok","ok")
}
function d()
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.removeChild(o[i])
}
</script>
2,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"><br>
3,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"><br>
<input type=button value=delete onclick="d()" UNSELECTABLE=true>
<script>
var n = 0
function f(u)
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file") o[i].setAttribute("ok","")
u.setAttribute("ok","ok")
}
function d()
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.removeChild(o[i])
}
</script>
解决方案 »
- 获取元素位于浏览器左端的距离发现不兼容,如何处理
- div 滚动 支持键盘上下键
- (求高人指点)jQuery获取使用HTML中动态DIV的ID值
- 请教JS数组赋值问题,急急急!!!
- window.location.href跳转之后怎么获得后面带参数的值急
- 在IE下添加节点并给该节点加一个onclick事件的问题
- JS循环问题
- 正则表达式问题
- 谁有Antechinus JavaScript Editor Pro 4的注册器啊?
- 请问在JS中怎样给一个图标加上超连接?点击图标转到另一个页面(急)
- 如何改变两个层的位置关系?
- 请问:网站中如何实现选择文件夹的对话框,类似选择文件的对话框的那样,非常感谢!
2,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"><br>
3,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"><br>
<input type=button value=delete onclick="d()" UNSELECTABLE=true>
<script>
var n = 0
function f(u)
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file") o[i].setAttribute("ok","")
u.setAttribute("ok","ok")
}
function d()
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.removeChild(o[i])
}
</script>
但是如何清除删除控件留下的空白呢?
我想把控件间排紧凑点。
<div>1,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"></div>
<div>2,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"></div>
<div>3,<INPUT type="file" size="50" NAME="File" onfocus="f(this)"></div>
<input type=button value=delete onclick="d()" >
<script>
var n = 0
function f(u)
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file") o[i].setAttribute("ok","")
u.setAttribute("ok","ok")
}
function d()
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.parentNode.removeChild(o[i].parentNode)
}
</script>
而且格式也比较好掌握
我用以下函数增加fiel控件,按你的方法加了<div>就有错误了。function addFile()
{
var str = '<div>
<INPUT type="file" size="50" NAME="File" onfocus="f(this)" br></div>'
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
}
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY>
<TABLE>
<TR>
<TD id="MyFile"><div><INPUT type="file" size="50" NAME="File" onfocus="f(this)"></div>
<div><INPUT type="file" size="50" NAME="File" onfocus="f(this)"></div>
<div><INPUT type="file" size="50" NAME="File" onfocus="f(this)"></div></TD>
</TR>
</TABLE><input type=button value=delete onclick="d()" >
<script>
var n = 0
function f(u)
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file") o[i].setAttribute("ok","")
u.setAttribute("ok","ok")
}
function d()
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.parentNode.removeChild(o[i].parentNode)
}
function addFile()
{
var str = '<div> <INPUT type="file" size="50" NAME="File" onfocus="f(this)" br></div>'
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
}
</script>
<INPUT TYPE="button" value ="添加" onclick="addFile()">
</BODY>
</HTML>
没错呀!