且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

视频加载后的jQuery加载功能

更新时间:2023-12-04 22:55:34

HTML元素视频没有加载事件。它有其他,如 loadstart loadeddata loadedmetadata 。查看此处可能的视频事件的完整列表。

HTML element video does not have load event. It has others, like loadstart, loadeddata or loadedmetadata. See a full list of possible viedo events here.

$("#abc").on("loadstart", function() {
  console.log(3);
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<video id="abc" preload="auto" autoplay="autoplay" loop="loop" webkit-playsinline="">
  <source src="https://www.quirksmode.org/html5/videos/big_buck_bunny.mp4" type="video/mp4">
</video>

loadeddata :当浏览器加载了音频/视频的当前帧时触发>
loadedmetadata :当浏览器加载音频/视频的元数据时触发

loadstart :浏览器开始查找时触发音频/视频

loadeddata: Fires when the browser has loaded the current frame of the audio/video
loadedmetadata: Fires when the browser has loaded meta data for the audio/video
loadstart: Fires when the browser starts looking for the audio/video