我想在特定列的每个表单元内实现Jquery Mask Money。下面是我想要实现的代码:
HTML表格代码
<script src="js/jquery.maskMoney.js"></script>
<div class="container">
<table id="users_data" class="table table-striped table-bordered" >
<tr>
<th>Name</th>
<th>product</th>
<th>Price</th>
</tr>
<tr>
<td>Jill</td>
<td>Beer</td>
<td ><input type="text" id="price" value="94"></td>
</tr>
<tr>
<td>Eve</td>
<td>Bread</td>
<td ><input type="text" id="price" value="34"></td>
</tr>
</table>
</div>
<script>
$('#users_data tr').each(function() {
$("#price").maskMoney({prefix:'R$ ',allowNegative: false,thousands:'.',decimal:',',affixesStay: true});
});
</script>
上面的代码显示带有相应数据的表,但是MaskMoney插件仅在第一个单元格内起作用。我尝试了jQuery each。()函数来执行此操作,但没有响应。在这种情况下,如何改善我的代码来解决这个问题?谢谢。