【问题标题】:jQuery snippet don't work in my wordpress themejQuery 片段在我的 wordpress 主题中不起作用
【发布时间】:2014-01-21 01:16:56
【问题描述】:
【问题讨论】:
标签:
javascript
jquery
html
wordpress
css
【解决方案1】:
jQuery 和 WordPress 之间似乎存在冲突,尝试将代码放入闭包中:
(function($){
$('.goFlip').on("click", function(){
$('.aboutMe').toggleClass('rotate-3d');
$('.card-back').toggleClass('z-up');
$('.card-back > .aboutHeader > h2').addClass('fadeInUp');
$('.backContent-wrap .backContent').addClass('fadeInUp');
});
})(jQuery);
【解决方案2】:
如果您在加载页面时查看控制台,您会发现它无法加载很多插件(即 404 not found 错误):
GET http://felipemartinin.com.br/wp-content/plugins/revslider/rs-plugin/css/captions.css?ver=3.8 404 (Not Found) felipemartinin.com.br/:37
GET http://felipemartinin.com.br/wp-content/plugins/revslider/rs-plugin/css/settings.css?ver=3.8 404 (Not Found) felipemartinin.com.br/:36
GET http://felipemartinin.com.br/wp-content/plugins/woocommerce/assets/css/woocommerce.css?ver=3.8 404 (Not Found) felipemartinin.com.br/:46
GET http://felipemartinin.com.br/wp-content/plugins/revslider/rs-plugin/js/jquery.themepunch.plugins.min.js?ver=3.8 404 (Not Found) felipemartinin.com.br/:49
GET http://felipemartinin.com.br/wp-content/plugins/revslider/rs-plugin/js/jquery.themepunch.revolution.min.js?ver=3.8 404 (Not Found) felipemartinin.com.br/:50
GET http://felipemartinin.com.br/wp-content/plugins/woocommerce/assets/js/frontend/add-to-cart.min.js?ver=2.0.20 404 (Not Found) (index):601
GET http://felipemartinin.com.br/wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js?ver=2.60 404 (Not Found) (index):602
GET http://felipemartinin.com.br/wp-content/plugins/woocommerce/assets/js/frontend/woocommerce.min.js?ver=2.0.20 404 (Not Found) (index):609
GET http://felipemartinin.com.br/wp-content/plugins/woocommerce/assets/js/jquery-placeholder/jquery.placeholder.min.js?ver=2.0.20 404 (Not Found) (index):603
GET http://felipemartinin.com.br/wp-content/plugins/woocommerce/assets/js/jquery-cookie/jquery.cookie.min.js?ver=1.3.1 404 (Not Found) (index):610
GET http://felipemartinin.com.br/wp-content/plugins/woocommerce/assets/js/frontend/cart-fragments.min.js?ver=2.0.20 404 (Not Found)
首先,您应该避免此类错误。然后查看文件在服务器上的位置,并更正路径。