【问题标题】:Sidr Plugin not working for my Wordpress SiteSidr 插件不适用于我的 Wordpress 网站
【发布时间】:2013-11-28 23:25:24
【问题描述】:

我最近尝试为我的自定义 wordpress 主题安装 jQuery Slidr 插件,但没有任何运气让它工作。当我尝试通过将侧边栏绑定到我的“#mobile-menu”锚标记来调用侧边栏时,我在控制台中收到此错误,“TypeError: $(...).sidr is not a function”。

这是我的代码的布局方式:

functions.php

function wpbootstrap_scripts_with_jquery()
{

wp_register_script( 'init', get_template_directory_uri() . '/javascripts/initialize.js' , array( 'jquery' ), '1.0', true );
wp_register_script( 'sidr', get_template_directory_uri() . '/javascripts/jquery.sidr.min.js' , array( 'jquery' ), '1.0', true );


wp_enqueue_script( 'init' );
wp_enqueue_script( 'sidr' );

}
add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );

initialize.js

(function($) {
$('#mobile-menu').sidr();
})(jQuery);

链接到我的网站:http://www.xboxoneachievementguides.com

【问题讨论】:

    标签: jquery wordpress


    【解决方案1】:
    jQuery(document).ready(function(){
         jQuery('#mobile-menu').sidr();
        })
    

    请试试这个,我已经检查了它的运行情况

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-07
      • 2013-11-27
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      • 2017-07-28
      • 1970-01-01
      • 2016-08-03
      相关资源
      最近更新 更多