第一次加载/硬刷新时​​的jQuery加载问题

编程入门 行业动态 更新时间:2024-10-27 14:32:19
本文介绍了第一次加载/硬刷新时​​的jQuery加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好,这是下面的网站

hey everyone, here is the site SEE BELOW

我有一个轻微的jquery问题,我似乎无法弄清楚如何调试它.

I have a slight jquery problem and I cant seem to figure out how to debug it.

当您将鼠标悬停在缩略图上时,该滚动条应会滚动.当页面加载或加载硬刷新时,它们不会滚动.

the strip of thumbnails is supposed to scroll when you hover over it. When the page loads, or it loads on a hard refresh, they dont scroll.

如果我刷新页面(通常不是硬刷新),它就可以正常工作.

If I refresh the page (normally, not a hard refresh), it works fine.

有什么想法吗?

---------------- UPDATE -------------------

----------------UPDATE-------------------

这是一个干净的版本,没有其他代码:

Here is a clean version with no other code in the way:

在此处链接

这是我用来生成滚动条的JS代码

And Here is the JS Code I am using to produce the scroll

请参阅下半部分以获取使它滚动的代码.

See the second half for the code that makes it scroll.

$(document).ready(function() { $('#slideshow').cycle({ fx: 'fade', next: '#next', pause: 1, prev: '#prev', pause: '#pause', pager: '.thumbs', pagerClick:function(zeroBasedSlideIndex, slideElement) {$(slideElement).find('div.cover').hide();}, pagerAnchorBuilder: function(idx, slide) { var src = $('img',slide).attr('src'); //Change height of thumbnail here return '<li><a href="#"><img src="' + slide.src + '" width="75" /></a></li>'; // return '<li><a href="#"><img src="' + src + '" height="90" /></a></li>'; } }); $(function() { //Pause slideshow on page load $("#slideshow").cycle('pause'); }); //Get our elements for faster access and set overlay width var div = $('div.sc_menu'), ul = $('ul.sc_menu'), ulPadding = 15; //Get menu width var divWidth = div.width(); //Remove scrollbars div.css({overflow: 'hidden'}); //Find last image container var lastLi = ul.find('li:last-child'); //When user move mouse over menu div.mousemove(function(e){ //As images are loaded ul width increases, //so we recalculate it each time var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding; var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth; div.scrollLeft(left); }); });

推荐答案

也许您可以发布代码,比浏览页面更容易找到您所指的内容...

Maybe if you could post the code it'd be easier than browsing the page for the exact include you're referring to...

无论如何,我 bet 您并没有将init方法封装在确保DOM完全加载的状态下:

Anyway, I bet you're not enclosing your init methods how they should be to ensure the DOM is entirely loaded:

$(function (){ // Put everything you want to run on page load here, to ensure it's // only run when the DOM has loaded entirely. });

更多推荐

第一次加载/硬刷新时​​的jQuery加载问题

本文发布于:2023-10-12 21:42:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!