将div标签脚本复制到输入标签

时间:2014-12-11 10:04:21

标签: javascript php jquery html ajax

我想在点击事件中将div标签动作复制到输入框。在div标签中显示日历。

<div id="datepicker"></div>
<input id="datepicker" type="date" name="sample">
<script src="external/jquery/jquery.js"></script>
<script src="jquery-ui.js"></script>
<script>
    $("#datepicker").datepicker({
        inline: true
    });
</script>

1 个答案:

答案 0 :(得分:1)

只需在点击事件上显示datepicker,如下所示:

<div id="datepickerContainer"> <!---- ID should be unique ---------->
</div>
<input id="datepicker" type="date" name="sample">

 <script src="external/jquery/jquery.js"></script>
 <script src="jquery-ui.js"></script>
  <script>
  $( "#datepicker" ).datepicker({
        inline: true
  });
  $('#datepickerContainer').on('click',function() { 
       $( "#datepicker" ).datepicker('show'); 
  });
 </script>