Javascript 如果使用js在动态表中选择重复值,如何警告消息?
我在表中选择名称,然后单击+按钮创建动态行,如果我单击相同的名称,它将提示消息。到目前为止我很累,但没有反应 js代码Javascript 如果使用js在动态表中选择重复值,如何警告消息?,javascript,Javascript,我在表中选择名称,然后单击+按钮创建动态行,如果我单击相同的名称,它将提示消息。到目前为止我很累,但没有反应 js代码 <script> $('#addMore3').on('click',function() { alert('ok'); var tableRows = $("#tb3 tbody tr"); tableRows.each(function(n){ var id = this.id; var row = $(this).val();
<script>
$('#addMore3').on('click',function() { alert('ok');
var tableRows = $("#tb3 tbody tr");
tableRows.each(function(n){
var id = this.id;
var row = $(this).val();
tableRows.each(function(n){
var $this;
if(this.id != id){
$this = $(this);
if ($this.val() == row){
alert('o');
}
}
});
});
});
</script>
$('#addMore3')。在('click',function(){alert('ok');
var tableRows=$(“#tb3 tbody tr”);
tableRows.each(函数(n){
var id=this.id;
var行=$(this.val();
tableRows.each(函数(n){
var$这个;
if(this.id!=id){
$this=$(this);
如果($this.val()==行){
警报('o');
}
}
});
});
});
查看代码:
<tbody>
<tr >
<td><a href='javascript:void(0);' class='remove3'><span class='glyphicon glyphicon-remove'></span></a></td>
<td><select name="m1[]" id="name" class="form-control border-slate border-lg" style="height:35px; width:300px; " >
<option></option>
<?php foreach ($pname as $row ): ?>
<option><?=$row->name ?></option>
<?php endforeach ?>
</select></td>
<td><a href="javascript:void(0);" style="font-size:18px;" id="addMore3" title="Add More Person"><span class="glyphicon glyphicon-plus"></td>
</tr>
</tbody>
是HTML的select标记还是表中的某个自定义下拉列表?这个名字有唯一的id吗?是的,它是选择标签有唯一的id我编辑了代码,它是HTML的选择标签还是表中的某个自定义下拉列表?此名称是否具有唯一id?是的,是选择标记具有唯一id我编辑了代码