我正在尝试向我的网站添加一个简单的预加载器,但我在控制台中收到此错误 Uncaught TypeError: a.indexOf is not a function
HTML 索引.html
<html class="js">
<head>
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(window).load(function(){
$('#preloader').fadeOut('slow',function(){$(this).remove();});
});
});
</script>
<div id="preloader"></div>
</body>
</html>
CSS 样式.css
.js div#preloader {
position: fixed;
left: 0;
top: 0;
z-index: 999;
width: 100%;
height: 100%;
overflow: visible;
background: #143441 url('assets/img/loader.gif') no-repeat center center;
}
这只显示了一个不断旋转和加载结束后的 gif..
最佳答案
我搜索了一下,找到了解决方案。问题出在.load
事件别名,需要更换.on
例子:
$(window).load(function(){...});
变成:
$(window).on('load', function(){ ...});
关于javascript - 未捕获的 TypeError : a. indexOf 不是函数 [PRELOADER],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55363084/