我已经使用timepicker动态创建了多个tr。我正在使用wickedpicker.min.js。我想根据锚标记点击获取相应时间戳值的值,即提交点击。
<tr>
<td id="output"></td>
<td>1001</td>
<td class="mdl-data-table__cell--non-numeric">Name</td>
<td class="mdl-data-table__cell--non-numeric">Disposal</td>
<td class="mdl-data-table__cell--non-numeric">
<input type="text" id="timepicker-24-hr" name="timepicker-24-hr" class="timepicker-24-hr mdl-textfield__input sstart">
</td>
<td class="mdl-data-table__cell--non-numeric">
<input type="text" id="timepicker-24-hr" name="timepicker-24-hr" class="timepicker-24-hr mdl-textfield__input eend">
</td>
<td class="mdl-data-table__cell--non-numeric">
<a href="#" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent btn-sm setAttn">submit</a>
</td>
</tr>
我用它来获取值:
$(document).on("click", ".setAttn", function(e){
e.preventDefault();
alert($(".sstart").val());
alert($(".eend").val());
});
答案 0 :(得分:0)
在此代码中尝试此代码我已使用jquery
并遍历所有input type=text
标记,它将读取所有值,直到设置的标记类型在HTML
页面中结束
$(document).on("click", ".setAttn", function(e) {
e.preventDefault();
$(".sstart").each(function() {
alert($(this).val());
})
$(".eend").each(function() {
alert($(this).val());
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td id="output"></td>
<td>1001</td>
<td class="mdl-data-table__cell--non-numeric">Name</td>
<td class="mdl-data-table__cell--non-numeric">Disposal</td>
<td class="mdl-data-table__cell--non-numeric">
<input type="text" id="timepicker-24-hr" name="timepicker-24-hr" class="timepicker-24-hr mdl-textfield__input sstart">
</td>
<td class="mdl-data-table__cell--non-numeric">
<input type="text" id="timepicker-24-hr" name="timepicker-24-hr" class="timepicker-24-hr mdl-textfield__input eend">
</td>
<td class="mdl-data-table__cell--non-numeric">
<input type="text" id="timepicker-24-hr" name="timepicker-24-hr" class="timepicker-24-hr mdl-textfield__input sstart">
</td>
<td class="mdl-data-table__cell--non-numeric">
<input type="text" id="timepicker-24-hr" name="timepicker-24-hr" class="timepicker-24-hr mdl-textfield__input eend">
</td>
<td class="mdl-data-table__cell--non-numeric">
<a href="#" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent btn-sm setAttn">submit</a>
</td>
</tr>
这是jsFiddle
答案 1 :(得分:0)
最后我找到了答案。 我用timepicker id绑定了数据的id,所以每次timepicker id现在都不同了。所以,我只是从时间戳ID中获取值。