jQuery 循环在 Chrome 和 IE 中不起作用
我正在使用这段代码:
jQuery(document).ready(function() {
jQuery('#slider-box').cycle({
fx: 'fade',
speed: '700',
timeout: 4000,
pager: '#slide-pager'
});
});
html 是:
这在 Firefox 中运行良好。但在 IE 和 Chrome 中不起作用。 我也尝试过 $ 符号。但它说函数未定义,因为我在某些地方使用 jQuery。
IE 说: 线路:135 角色:70 代码:0 错误消息:“this[...].style”为 null 或不是对象 网址: http://www.waqasalieee.com /wp-includes/js/jquery/jquery.js?ver=1.4.2
chrome 说(开发者工具中的控制台): 未捕获的类型错误:无法读取 null 的属性“defaultView”
I am using this code:
jQuery(document).ready(function() {
jQuery('#slider-box').cycle({
fx: 'fade',
speed: '700',
timeout: 4000,
pager: '#slide-pager'
});
});
and html is:
// some content
This is working well in firefox. But not working in IE and chrome.
I have also tried $ sign. But it says function not defined as i am using jQuery at places.
IE says:
Line: 135
Character: 70
Code: 0
Error Message: 'this[...].style' is null or not an object
URL: http://www.waqasalieee.com/wp-includes/js/jquery/jquery.js?ver=1.4.2
chrome says (console in developer tools):
Uncaught TypeError: Cannot read property 'defaultView' of null
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的 javascript 没有任何问题..也许你应该将你的 jquery 更新到最新版本。
There is nothing wrong with your javascript.. maybe you should update your jquery to newest version.
好的,这是正确的解决方案:
首先,我们需要禁用 WordPress 中的默认 jquery 包含,您可以通过以下方式执行此操作:
打开:wp-includes/script-loader.php
注释这一行: $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.4.2');
现在打开你的主题 header.php
并在标题部分包含此行:
问题已解决!
干杯!
再次感谢 Kim 让我开始朝这个方向思考。
Ok here is the proper solution:
first of all we need to disable default jquery inclusion in wordpress, you can do this by:
open: wp-includes/script-loader.php
comment this line: $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.4.2');
Now open your themes header.php
and include this line in header section:
Problem solved!
Cheers!
Once again thanks to Kim for clicking my mind to think in this direction.