2016-07-14 5 views
0
$(document).ready(
    /* This is the function that will get executed after the DOM is fully loaded */ 
    function() { 
     $("#datepicker").datepicker({ 
      changeMonth: true,//this option for allowing user to select month 
      changeYear: true //this option for allowing user to select from year range 
     }); 
    } 
); 

日付選択にdatepickerを使用しています。私は外部のjsファイルをHTMLページに含めましたが、それにはtype error $(..)datepicker is not functionのようなエラーがあります。datepickerを取得すると、エラーとして機能しない

+0

Jqueryが正常に読み込まれましたか? –

+0

'datepicker'プラグインへの参照を保持しましたか? –

+0

jQueryがロードされていることを確認して関数にコメントしてください。 –

答えて

0

あなたindex.htmlファイル <script src="yourDestination/jquery-ui.min.js></script>

に、これがない場合は、このファイルにSRCを追加する必要があり、あなたの開発環境にダウンロードした後jQuery UI

をダウンロードする必要がjQueryのユーザーインターフェイスプラグインを使用するためには再び働く。問題を見るためにいくつかのフィドルを提供してください

+0

はいすべての必要なJqueryユーザーインターフェイスプラグインを追加しました
<! - jQuery UIメインJSをロード - > <! - 入力フィールドの日付ピッカーを作成するSCRIPT.JSをロード - > Shilpa

0

私はエラー'<blank> is not function'を得るたびに、通常、私はその機能を利用できるようにするために必要なコードをインポートしていないことを意味します。

また、私はオブジェクトに適切に関連付けられた関数を呼び出さないことを意味する可能性があります。

私はライブラリ関数を動作させることができません。私は、その関数のオンラインサンプルを見て、他の依存ライブラリや必要な手順がないかどうか確認したいと思います。私たちはあなたのHTMLページにjquery.jsとjQuery-ui.jsのためのCDNのURLを修正する場合は、この例では、https://jqueryui.com/datepicker/

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>jQuery UI Datepicker - Default functionality</title> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css"> 
    <link rel="stylesheet" href="/resources/demos/style.css"> 
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
    <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script> 
    <script> 
    $(function() { 
    $("#datepicker").datepicker(); 
    }); 
    </script> 
</head> 
<body> 

<p>Date: <input type="text" id="datepicker"></p> 


</body> 
</html> 
0

に位置している必要なコンポーネントを持っている場合

を参照してください。私たちは必要な結果を得ることができます。正しい次のCDNのURLを試してください:

<html> 
<body> 
<label>Enter the license active date</label> 
<input type="text" id="datepicker" /><br>  
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>   
<!-- Load jQuery UI Main JS -->   
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>  
<!-- Load SCRIPT.JS which will create datepicker for input field --> 
<script src="JS/script.js"></script>  
</body>  
</html> 

とscript.jsが

$(document).ready(
    /* This is the function that will get executed after the DOM is fully loaded */ 
    function() { 
     $("#datepicker").datepicker({ 
      changeMonth: true,//this option for allowing user to select month 
      changeYear: true //this option for allowing user to select from year range 
     }); 
    } 
); 

はそれがために働くことを願っていますファイル:

<script src="https://code.jquery.com/jquery-1.9.1.js"></script>   
<!-- Load jQuery UI Main JS -->   
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 

全体のコードはその HTMLページのようになります君は。

+0

ありがとう – Shilpa

関連する問題