我希望在文件上传后启用禁用按钮。但是,我似乎无法启用它。
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<script type="text/javascript">
$('#FileUpload').on('change', function (e) {
Document.getElementById("btnUploadFile").className = "btn standard-gradient";
});
</script>
<asp:FileUpload ID="FileUpload" runat="server" class="btn"/>
<asp:Button runat="server" ID="btnUploadFile" Text="Upload File" OnClick="btnUploadFile_OnClick" class="btn standard-gradient disabled"/>
</asp:Content>
答案 0 :(得分:0)
试试这个脚本:
<script type = "text/javascript" >
$('#FileUpload').on('change', function (e) {
var btn = $("#btnUploadFile");
if (btn.prop("disabled")) { $("#btnUploadFile").prop('disabled', '') }
else { $("#btnUploadFile").prop('disabled', 'disabled') }
});
</script>
将此 JSFIDDLE 作为样本。
<强> HTML 强>
<button id="FileUpload">file</button>
<button id="btnUploadFile">btn</button>
<强> JS 强>
$('#FileUpload').on('click', function (e) {
var btn = $("#btnUploadFile");
if ( btn.prop( "disabled" ) ){
$("#btnUploadFile").prop('disabled', '')
}
else {$("#btnUploadFile").prop('disabled', 'disabled')}
});