jQuery $ window load函数在wordpress上不起作用

时间:2014-03-04 05:44:11

标签: jquery wordpress

我在wordpress上的index.php文件中使用此代码所有功能都正常工作只是这个功能无法正常工作。我已经使用了wp enque脚本所以现在我不知道什么是我需要你帮助的问题....

$(window).load(function () {
    $("#flexiselDemo1").flexisel();
    $("#flexiselDemo2").flexisel({
        enableResponsiveBreakpoints: true,
        responsiveBreakpoints: {
            portrait: {
                changePoint: 480,
                visibleItems: 1
            },
            landscape: {
                changePoint: 640,
                visibleItems: 2
            },
            tablet: {
                changePoint: 768,
                visibleItems: 3
            }
        }
    });

    $("#flexiselDemo3").flexisel({
        visibleItems: 5,
        animationSpeed: 1000,
        autoPlay: true,
        autoPlaySpeed: 3000,
        pauseOnHover: true,
        enableResponsiveBreakpoints: true,
        responsiveBreakpoints: {
            portrait: {
                changePoint: 480,
                visibleItems: 1
            },
            landscape: {
                changePoint: 640,
                visibleItems: 2
            },
            tablet: {
                changePoint: 768,
                visibleItems: 3
            }
        }
    });

    $("#flexiselDemo4").flexisel({
        clone: false
    });

});

1 个答案:

答案 0 :(得分:0)

jQueryWordpress here, try to convert $ to jQuery`之间可能存在冲突或使用:

jQuery(function($) {
    // Your code here
});

或将所有当前的jQuery代码包装在一个闭包中:

(function($){
    // Your code here
})(jQuery);