我想使用jquery.table值在表中显示最后一个重复值的错误消息,我正在添加dynamicaly.So怎么办?请分享您的想法以解决此问题。
$(document).ready(function() {
$("#btnSave").click(function() {
var arr = [];
var tblid = $("#comp tr");
tblid.each(function() {
arr.push($(this).find('td').find('span').attr('data-id'));
});
alert(arr);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="comp">
<tr>
<td><span data-id="kiste"></span>kiste
<p class="close">
Same Name so please change
</p>
</td>
</tr>
<tr>
<td><span data-id="Futiste"></span>Futiste
<p class="close">
Same Name so please change
</p>
</td>
</tr>
<tr>
<td><span data-id="kavi"></span>kavi
<p class="close">
Same Name so please change
</p>
</td>
</tr>
<tr>
<td><span data-id="kiste"></span>kiste
<p class="close">
Same Name so please change
</p>
</td>
</tr>
<tr>
<td><span data-id="Futter"></span>Futter
<p class="close">
Same Name so please change
</p>
</td>
</tr>
</table>
<button id="btnSave">Save Click</button>