$(function () { $("#ip").click(function() { $("html,body").animate({ scrollTop: $(".videoBox").offset().top }, 1000) }); $("#ai").click(function() { $("html,body").animate({ scrollTop: $("#aiText").offset().top }, 1000) }); $("#zb").click(function() { $("html,body").animate({ scrollTop: $(".coverF").offset().top }, 1000) }); $("#hz").click(function() { $("html,body").animate({ scrollTop: $(".teamworkBoxtop").offset().top }, 1000) }); $("#wm").click(function() { $("html,body").animate({ scrollTop: $(" .suimang ").offset().top }, 1000) }); let video1 = document.getElementById("video1"); let video2 = document.getElementById("video2"); video1.play(); window.onscroll = function () { var t = document.documentElement.scrollTop || document.body.scrollTop; //变量t就是滚动条滚动时,到顶部的距离 // video2.pause() if (t < 700) { video2.pause(); video1.play(); } else if (t >= 700) { video1.pause(); video2.play(); } } })