解决方案 »

  1.   

    你应该在添加到页面之后利用处理事件,可以考虑类似如下的效果
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>  <script>
      $(document).ready(function() {
    $('.date').datepicker();
    $('#btn').click(function(){
    $('.box').append('<input type="text" class="date" />');
    $('.box .date').each(function(index, element) {
                $(this).datepicker();//如果是autocomplete,你可以自定义属性来传值
            });;
    });
      });
      </script>
    </head>
    <body>
    <p>
    <input type="button" id="btn"  value="动态添加"/>
    </p>
    <div class="box">
    <input type="text" class="date" />
    </div></body>
    </html>