单击行的选择按钮时,会弹出一个确认框。
确认框后,选择按钮将被禁用,并附加一条应淡出的消息。
两者,按钮禁用和消息追加工作,但只有一秒钟。 该按钮不会保持禁用状态。此消息也正确附加,但也只是一秒钟。
我可以将fadeOut(Int)更改为任何整数但仍然只显示一秒钟。为什么功能只能工作一秒钟?
<script>
$('#button_<?php echo $platform->id; ?>').click(function() {
var choice = confirm('Please confirm that you wish to do the following Platform: <?php echo $platform->company; ?>');
if (choice == true) {
$('#button_<?php echo $platform->id; ?>').prop("disabled", true);
$('.job_confirm').css('visibility', 'visible');
$('.job_confirm').append('The Job has been added to your Userarea -->');
$('.job_confirm').fadeOut(5000);
}
});
</script>
答案 0 :(得分:5)
尝试event.preventDefault();
<script type="text/javascript">
$('#button_<?php echo $platform->id; ?>').click(function(event) {
event.preventDefault();
var choice = confirm('Please confirm that you wish to do the following Platform: <?php echo $platform->company; ?>');
if (choice == true) {
$('#button_<?php echo $platform->id; ?>').prop("disabled", true);
$('.job_confirm').css('visibility', 'visible');
$('.job_confirm').append('The Job has been added to your Userarea -->');
$('.job_confirm').fadeOut(5000);
}
});
</script>