I want to enable a disabled button after the file uploads. However, I can not seem to get it enabled.
<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>
try this script:
<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>
Check this JSFIDDLE as a sample.
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')}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.