【发布时间】:2017-07-11 21:55:10
【问题描述】:
我试图在单击按钮时显示微调器以指示浏览器正在幕后执行操作。微调器在我单击 Firefox 浏览器上的按钮后立即显示,而不是在 Google Chrome 浏览器上显示。在 Google Chrome 浏览器上会有 8 秒的延迟。我在执行操作时在开发人员工具上对其进行了调试,但我确实看到在单击按钮时将类属性添加到 html 代码中。
这是我的标记:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="loadSpinner" style="display:none;"></div>
<button type="submit" class="btn spinnerEvent" >On</button>
<script>
$(document).on("click", "button.spinnerEvent", function(event){
$('#loadSpinner').addClass('show'); //LOADS THE SPINNER
});
</script>
<style>
#loadSpinner.show{
background:#000 url(../images/spinner-small.gif) no-repeat center center;
background-color: transparent;
height: 128px;
width: 128px;
position: fixed;
z-index: 1000;
left: 50%;
top: 25%;
margin: -25px 0 0 -25px;
}
</style>
【问题讨论】:
-
您在 JS 中引用了标记中不存在的代码。您能否清理一下您的代码并提供给我们minimal reproducible example?
-
我实际上已经在 jsFiddle 上测试了我的代码,我看到微调器显示为单击按钮。我不明白为什么申请会有延迟。
-
您的代码可以正常工作。你的 jsfiddle 在哪里?
标签: javascript jquery html css google-chrome