我正在做一个文件上传的形式与下列按钮:“选择文件”,“上传”和“添加其他文件”
我试图删除属性“禁用”上传按钮时,文件输入更改)。它适用于第一个上传按钮,但不适用于第二个上传按钮等等...... 这是为什么?
非常感谢,如果你能帮助我。
我jQuery代码是:
$(document).ready(function() {
$('input[type=file]').change(function(){
$(this).next().removeAttr('disabled');
});
$('.add').click(function() {
var num = $('input[type=file]').length;
newNum = num + 1;
if (newNum >= 4){
$('.add').hide();
}
$('#addanother').append("<form method='POST'>");
$('#photo1').clone().attr('id','photo'+newNum).appendTo('#addanother');
$('#upload'+num).clone().attr('id','upload'+newNum).attr('disabled','disabled').appendTo('#addanother');
$('#addanother').append('</form><br />');
});
});
我的HTML代码是:
<form method='POST' enctype="multipart/form-data">
<input type='file' class='fileinput' id='photo1'>
<input type='button' id='upload1' name='upload1' value='Upload' disabled='disabled'>
</form>
<div id='addanother'></div>
<input type='button' class='add' id='add1' value='Add file'>
相反removeAttr看看在使用道具()http://api.jquery.com/prop/ – 2012-03-16 21:51:27
你好周杰伦,我要找进去。非常感谢。我发现removeAttr的行为如此令人困惑。这种行为没有合乎逻辑的理由。 – eric01 2012-03-16 21:55:16