我正在向我正在创建的表单添加一个 div。我想用这个函数来做这个on()
,但我似乎无法让它工作。据我了解,您必须使用事件,但是有没有办法从添加的 div 中创建事件。我一直在尝试的代码是带有“点击”事件的,但这并不是我真正想要的。在第一次单击后添加了日期选择器,但根本没有添加 buttonImage。我需要它在第一次点击时工作。这是我现在正在使用的代码:
$('#switcher-panel').on('click', 'table tr td input', function(){
$('.datepicker').datepicker({
buttonImage: "images/calendar.png"
});
});
这是我正在使用的html:
<table class="table table-hover" data-controller="rank">
<thead>
<tr>
<th colspan="4" align="left"><h2> Boy Scout Rank</h2></th>
</tr>
<tr>
<th>Number</th>
<th>Requirements</th>
<th>Completed</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr data-name="one_li">
<td>1</td>
<td>
Req
</td>
<td>
<input class="datepicker"/>
</td>
</tr>
</tbody>
</table>
我不明白如何处理这个。任何帮助都会很棒。