一加载当前批次的图片 for (let i = startIndex; i < endIndex; i++) { const img = $(images[i]); const imgSrc = img.data('original'); // 获取图片的原始路径 // 如果原始路径存在,设置src属性和移除lazy类 if (imgSrc) { img.attr('src', imgSrc).removeClass('lazy'); } } // 更新索引 index += batchSize; // 如果还有图片未加载,设置延迟后加载下一批次 if (index < images.length) { setTimeout(loadNextBatch, delay); } } // 开始加载第一批 loadNextBatch(); } // 获取所有懒加载图片 $(document).ready(function() { const lazyImages = $("img.lazy"); // 设置每次加载5张图片,设置延迟为1000毫秒(可以根据需要调整) loadImagesInBatches(lazyImages, 5, 1000); }); $(function () { $('.sidebar-btn').click(function () { //给触发按钮绑定点击事件,也就是鼠标点击触发按钮后执行的动作 if ($('.read-section').css('left') == "0px") $('.read-section').animate({left: '-212px'}, 200); //把左边栏的宽度设置为原来的宽度并显示出来, 根据设定的时间慢慢展现 else $('.read-section').animate({left: '0px'}, 200); //把左边栏的宽度设置为原来的宽度并显示出来, 根据设定的时间慢慢展现 }); //--本地缓存代码开始-- let bookInfo = { chapter_id: '1230745', end: "连载", chapter_name: '发现重点', cover_url:'https://static-tw.baozimhcn.com/cover/moshimoling-shuanggongzuoshi.jpg', book_id: '13958', last_time: "2025-02-27", book_name:'万事万灵', param: '29573' }; localStorage.setItem('manhua_13958', JSON.stringify(bookInfo));//id为键,设置缓存 let history = []; let value = localStorage.getItem('xwx_historys'); //读取参照数组 if (value != undefined && value != null) { history = JSON.parse(value); } if (history.indexOf('manhua_13958') === -1) { history.push('manhua_13958'); //把id为值存入参照数组 } localStorage.setItem('xwx_historys', JSON.stringify(history)); //--本地缓存代码结束-- if (document.images) { for (i = 0; i < document.images.length; i++) { document.images[i].onmousedown = function () { return false; }; } } }); 返回顶部