Jquery 具有for循环的html页面中的日期选择器在第二个实例之后不起作用

Jquery 具有for循环的html页面中的日期选择器在第二个实例之后不起作用,jquery,html,for-loop,datepicker,Jquery,Html,For Loop,Datepicker,我在html页面中使用datepicker,它在for循环的第一个实例中工作正常,但在for循环条件的第二个实例中,datepicker不工作 jquery的版本是 <link href="jQueryAssets/jquery.ui.datepicker.min.css" rel="stylesheet" type="text/css"> <script src="jQueryAssets/jquery.ui-1.10.4.datepicker.min.js" type="t

我在html页面中使用datepicker,它在for循环的第一个实例中工作正常,但在for循环条件的第二个实例中,datepicker不工作

jquery的版本是

<link href="jQueryAssets/jquery.ui.datepicker.min.css" rel="stylesheet" type="text/css">
<script src="jQueryAssets/jquery.ui-1.10.4.datepicker.min.js" type="text/javascript"></script>

我的html表单中的代码部分如下所示。 我想用datepicker在for循环中运行表单。 但是日期选择器只是第一次出现。。。。?? 请帮忙

<table align="center">
<?php
$wno = $_POST['no'];
$wname = $_POST['name'];    
?>
    <form method='post' action=''>
        <tr>    
            <td colspan='2' align="center"><input type='text' name='no' class='tfield' value="<?php echo$wno?>" readonly /></td>
            <td colspan='2' align="center"><input type='text' name='name' class='tfield' value="<?php echo$wname?>" readonly /></td>
        </tr>
        <tr>
            <th class='tabdata'>Log</th>
            <th class='tabdata'>Top Depth</th>
            <th class='tabdata'>Bottom Depth</th>
            <th class='tabdata'>Date of Log</th>
        </tr>   
<?php 
        $number=$_POST['nologs'];
        for($i=1;$i<=$number;$i++){
?>  

        <tr>
            <th colspan="4" align="center" class='tabdata'>File No: <?php echo$i?></th>
        </tr>
        <tr>
            <td>
                <input name='logs[]' type='text' required="required" placeholder="Logs" autocomplete="off" class='tabdata'>
            </td>

            <td>
                <input type='float' required="required" name='bottom[]' placeholder="Bottom Depth" class='tabdata'>
            </td>

            <td>
                <input type='float' required="required" name='top[]' placeholder="Top Depth" class='tabdata'>
            </td>

            <td>
                <input type='text' required="required" id="datej" name='date[]' placeholder="Date of Logging" class='tabdata'>  
            </td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
<?php } ?>
        <tr>
            <td colspan='4' align='center'><input type='submit' value='Save' name='submit' class='button'/></td>
        </tr>
    </form>
    </table>
  </div>
</div>
<script type="text/javascript">
$(function() {
$( "#datej" ).datepicker({
}); 
});
</script>

档案编号:
$(函数(){
$(“#datej”).datepicker({
}); 
});

您需要通过
(例如
$('datej')
)来完成,而不是在
id上实例化它(例如
$('datej')
)。有效的HTML只使用
id
一次,因此如果您有多个具有相同
id
的对象,则该HTML无效。选择器的工作方式它只会选择
id

的第一个实例。谢谢,现在当我使用class而不是id时,它工作了