【发布时间】:2015-03-04 05:53:37
【问题描述】:
我创建了一个进度条来显示文件上传的进度。现在我正在尝试在进度条旁边创建一个“取消上传”按钮。
进度条JQuery的代码是:
(function () {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
var percentVal = '0%';
var x = 1;
var y = null; // To keep under proper scope
$('form').ajaxForm({
beforeSend: function () {
status.empty();
percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function (event, position, total, percentComplete) {
percentVal = percentComplete + '%';
if (percentVal != '100%')
{
bar.width(percentVal)
percent.html(percentVal);
}
//console.log(percentVal, position, total);
},
//success: function () {
// var percentVal = '95%';
// bar.width(percentVal)
// percent.html(percentVal);
//},
complete: function () {
percentVal = '100%';
bar.width(percentVal)
percent.html(percentVal);
delay(500);
location.reload();
}
});
})();
现在是取消按钮输入标签:
$(document).ready(function () {
$('#cancel').click(function () {
location.reload();
});
});
jQuery 插件:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
现在,如果我单击“取消”按钮,图像仍会上传。有人可以帮我解决“取消”按钮。谢谢
【问题讨论】:
标签: javascript jquery html progress-bar