简体   繁体   中英

After page refresh jquery stops working

这真是一个奇怪的问题,我的页面中有很多插件和自定义脚本,而且一切正常,但是如果我想尝试刷新页面,不只是点击一些链接,我的一些脚本就会停止工作,主要是改变css属性的人,我的firebug没有显示任何错误,可能导致类似的东西?

Answer from original poster:

So the problem was that i used $(document).ready() what i realy needed was $(window).load()

I know this is an old question I stumbled upon. Anyway, my answer might help another when the same problem arises. Unfortunately I haven't got the reputation to comment on Trott's answer above.

That being said, if you are using jQuery 1.8 or any version after his, then use $(window).on('load', function() { ... }); . The $(window).load() was deprecated in jQuery version 1.8 and will throw the error jquery url.indexOf is not a function (at least in jQuery 3.4.1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM