大家为什么这段JavaScript代码不会在Firefox上JavaScript的问题 - 火狐
工作var nfiles = 1;
function Expand(){
nfiles++
var adh = '<input type="file" name="File '+nfiles+'">';
files.insertAdjacentHTML('BeforeEnd',adh);
return false;
};
大家为什么这段JavaScript代码不会在Firefox上JavaScript的问题 - 火狐
工作var nfiles = 1;
function Expand(){
nfiles++
var adh = '<input type="file" name="File '+nfiles+'">';
files.insertAdjacentHTML('BeforeEnd',adh);
return false;
};
它看起来像你的变量后没有分号。
下面显示的是适用于包括Firefox在内的所有浏览器的工作Expand function
。
参考:jsFiddle。
function Expand() {
nfiles++;
var files = document.getElementById('test');
var adh = '<input type="file" name="File ' + nfiles + '">';
files.insertAdjacentHTML('afterend', adh);
return false;
}
感谢您对备选使用引号的评论。干杯! – Tom
欢迎您。附注:我看了你的开放性问题,看看我能提供什么帮助。你应该希望更多地关注你的一个问题。干杯! – arttronics
谢谢!有效。 – user622639
我不知道这个功能的来源,所以我不能说任何东西:
files.insertAdjacentHTML('BeforeEnd',adh);
这是写下面一行的另一种方式;它对我来说感觉很清晰,但我必须承认它是个人品味:
var adh = "<input type=\"file\" name=\"File " + nfiles + "\">";
并放一个;之后的行:
nfiles++
感谢您的帮助 – user622639
尝试使用[萤火虫]来分析这个问题(https://addons.mozilla.org/ EN-US /火狐/插件/萤火虫/)。 – Nick
你得到了什么错误? –