2017-04-21 89 views
0

我正在設置請求報價,該報價是使用取件日期和返回日期。 jquery datepicker小部件在拾取日期時效果很好,但不能在返回日期工作。是否有任何理由在同一表格中不能使用兩次?我使用的是相同的代碼http://jqueryui.com/datepicker/爲什麼jquery datepicker只能在同一個表單中工作一次?

<head> 
    <link rel="stylesheet" 
    href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> 
    <link rel="stylesheet" href="/resources/demos/style.css"> 
</head> 
    . 
    . 
    . 
<body> 
    <p>Date: <input type="text" id="datepicker"></p> 

    <script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
    <script> 
     $(function() { 
     $("#datepicker").datepicker(); 
         }); 
    </script> 
</body> 
+1

您只將日期選擇器設置爲使用ID爲datepicker的元素,並且無法重新使用ID。 – j08691

回答

0

使用class instead id。

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

並且不要忘記class的改變腳本;

<script> 
     $(function() { 
     $(".datepicker").datepicker(); 
         }); 
    </script> 
+0

非常感謝。我有一個想法,但不確定。 –

+0

不客氣 –