2015-10-14 58 views
0

我想在Wordpress(版本4.3.1)中的我自己的主題中實現日期選擇器。可惜沒有成功。我認爲一個問題是,我有一個SSL證書。Wordpress中的日期選擇器自己的主題

我的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 is not defined

沒有任何人有同樣的問題?

Greets,yab86

+0

謝謝Rohit。我在上面添加了我的代碼。 – yab86

回答

0

jQuery庫在執行此代碼時未加載。確保在編寫任何jQuery代碼之前加載jQuery庫。

你可以通過在<head>以上的任何其他JavaScript加載jQuery來解決這個問題。

+0

謝謝德文。但是這並沒有解決我的問題。 – yab86

相關問題