批改状态:合格
老师批语:
轮播图的自动翻页功能是将click事件派发给下一页按钮,并且这种派发,没隔2秒钟执行一次,从而实现自动翻页的功能。
// 自动翻页// 定义一个click的事件对象const autoTurn = new Event("click");//获取下一页按钮const next = document.querySelector(".skip .next");//每隔2秒执行一次,将click事件派发给next按钮setInterval(() => next.dispatchEvent(autoTurn), 2000);
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号