我有一个脚本应该只在桌面上显示加载视频,并且只在移动设备上显示图片横幅。这在firefox和chrome中运行良好,但视频在徒步旅行中根本无法加载。
控制台显示以下错误:
[Error] TypeError: a.indexOf is not a function. (In 'a.indexOf(" ")', 'a.indexOf' is undefined)
load (jquery.min.js:4:18902)
Global Code (uiscripts:1:22070)
[Error] TypeError: undefined is not an object (evaluating '$.validator.addMethod')
(anonymous function) (jquery.min.js:2:31697)
我的HTML是:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(
function() {
var bgv = $('#bgvid');
if (bgv.is(':visible')) {
$('source', bgv).each(
function() {
var el = $(this);
el.attr('src', el.data('src'));
}
);
bgv[0].load();
}
}
)
</script>
<style>
.hidden {
display: none;
}
@media screen and (min-width: 400px) {
.hidden {
display: block;
}
}
</style>
<video id="bgvid" class="hidden hidden-xs" autoplay loop>
<source type="video/mp4" data-src="my-video.mp4"></source>
</video>
<img alt="" class="visible-xs" src="my-image.jpg" style="width: 100%; height: auto;" />