Wordpress中的Datepicker自己的主题

时间:2015-10-14 22:37:15

标签: php jquery wordpress datepicker

我正在尝试在Wordpress(版本4.3.1)中使用我自己的主题实现datepicker。很遗憾没有成功。我认为有一个问题是,我有SSL证书。

我的functions.php

function datep_scripts() {
  wp_enqueue_script( 'jquery' );
  wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );

  wp_register_style( 'bootstrap_css', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css' );
  wp_enqueue_style( 'bootstrap_css' ); 

  wp_register_style('jquery-ui', get_template_directory_uri() .'/js/jquery-ui.css');
  wp_enqueue_style( 'jquery-ui' );   
}

add_action( 'wp_enqueue_scripts', 'datep_scripts' );

我的page.php

<input type='text' name="event_date" id="EventDate" class="form-control input-lg"/>
....
 <script type="text/javascript">
    //show calendar windows
    jQuery(document).ready(function() {
        jQuery('#EventDate').datepicker({
            dateFormat : 'dd.mm.yy'
        });
    }); 
</script>

我总是收到错误消息:

  

ReferenceError:未定义jQuery

有人有同样的问题吗?

Greets,yab86

1 个答案:

答案 0 :(得分:0)

执行此代码时未加载jQuery库。确保在编写任何jQuery代码之前加载jQuery库。

你可以通过在<head>上面加载jQuery来解决这个问题。

相关问题