draw datepicker dynamically

draw datepicker dynamically

  1.  <link rel="stylesheet" href="css/jquery-ui-1.9.2/themes/base/jquery-ui.css" />
  2.  <script src="css/jquery-ui-1.9.2/jquery-1.8.3.js"></script>
  3.  <script src="css/jquery-ui-1.9.2/ui/jquery-ui.js"></script>

  4.  <script>
  5. $(function() {
  6. $("#datepicker").datepicker({ dateFormat: "yy-mm-dd" }).val()
  7. });
  8.  </script>
  9. <script language="javascript">
  10. function add_new()
  11. {
  12.       ....

  13.       mydiv.innerHTML = mydiv.innerHTML +"<input type='text' class='datepicker'>";
  14. }
  15. </script>
i want the datepicker to be generate dynamically, but somehow with my code above, there only a textbox is generating. it seems unable to call out the class. but when i put " <input type='text' class='datepicker'> in php, it work fine for me.
anything went wrong? or i shouldn't do in this way?