How can I disable an element using jQuery Multifile?
This code does 开发者_开发百科not disable my element as expected
if(Multifile.n==0){
$("#btnUpload").attr("disabled","disabled");
}
This code does not enable my element as expected
$("#btnUpload").attr("disabled","");
I added these lines in jQuery.MultiFile.js after what I believe is the location where files are added and removed from the MultiFile object. As far as I can tell, MultiFile.n
is a counter.
How can I disable btnUpload when there are no files in the list, and enable it as long as there is at least one.
If there is a disabled attribute on the element, it will always be disabled, even if the attribute is empty. This is because the original (SGML variant of) HTML had attributes without values like this
<INPUT TYPE="text" DISABLED>
So you have to remove the attribute
$('#btnUpload').removeAttr('disabled');
精彩评论