这个在ie下删除(d.setAttribute("onclick", "deteFile(this)");)没有实现,在ff下可以,问怎么修改才可以在ie下实现
<script type="text/javascript">
function addFile() {
var div = document.createElement("div");
var f = document.createElement("input");
f.setAttribute("type", "file")
f.setAttribute("name", "File")
f.setAttribute("size", "50")
div.appendChild(f)
var d = document.createElement("input");
d.setAttribute("type", "button")
d.setAttribute("onclick", "deteFile(this)");
d.setAttribute("value", "移除")
div.appendChild(d)
document.getElementById("_container").appendChild(div);
} function deteFile(o) {
while (o.tagName != "DIV") o = o.parentNode;
o.parentNode.removeChild(o);
}
</script>
<script type="text/javascript">
function addFile() {
var div = document.createElement("div");
var f = document.createElement("input");
f.setAttribute("type", "file")
f.setAttribute("name", "File")
f.setAttribute("size", "50")
div.appendChild(f)
var d = document.createElement("input");
d.setAttribute("type", "button")
d.setAttribute("onclick", "deteFile(this)");
d.setAttribute("value", "移除")
div.appendChild(d)
document.getElementById("_container").appendChild(div);
} function deteFile(o) {
while (o.tagName != "DIV") o = o.parentNode;
o.parentNode.removeChild(o);
}
</script>
解决方案 »
- 大家好,我想问一下在jQuery中如何获取上一个网页传过来的request.querystring的值
- 关于传统模型与内联模型的涵数参数的问题
- 关于 CheckBox全选的问题..请大家看看我的JS哪写错了...
- 定义一个对象时:var O=new Object() 与 var O={}两种定义在哪里不一样
- **********请问关于js操作table的问题,马上揭贴************
- select的输入是否可以支持从键盘输入,并且可以从列表中动态匹配与输入的信息最接近的项目?
- 请看如下代码,有没有好的办法?我不知道I的最大值是多少,这样写下去总不是办法!
- 模态窗口问题(刷新)
- 以下代码错在那里?
- 急救—--做一个网页—--本人给分率是100%
- jquery怎么获得从json里读取到的id
- javascript的问题,(高分求助)
这句确实有兼容性问题
请尝试使用attachEvent来做
d.attachEvent("onclick","deteFile(this)");
而在ff下可以使用你的setAttribute也可以使用addEventListener
这样试试看
试试看这样的
d.setAttribute("onclick", "\"deteFile(this)\"");
GOOGLE下
addEventListener attachEvent 就明白了
使用这个会JavaScript出错
d.setAttribute("onclick", "\"deteFile(this)\""); 这个也实现不了