找到2个具有非唯一ID的元素 [英] Found 2 elements with non-unique id
本文介绍了找到2个具有非唯一ID的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们在两个不同的form
标签中使用相同的id
名称时,会收到以下警告.
I am getting the following warnings when we use with the same id
names in two different form
tags.
[DOM]找到2个具有非唯一ID的元素
[DOM] Found 2 elements with non-unique id
这是我的HTML代码段:
Here is my HTML snippet:
<div class="modal-dialog">
<form action="" method="post" id="myid-1" name="myid-1">
<input type="text" class="form-control" id="Job_Name" name="Job_Name" required="">
<label for="Job_Name">Job Name<span class="text-danger">*</span></label>
<button type="submit">Submit</button>
</form>
</div>
<div class="modal-dialog">
<form action="" method="post" id="myid-2" name="myid-2">
<input type="text" class="form-control" id="Job_Name" name="Job_Name" required="">
<label for="Job_Name">Job Name<span class="text-danger">*</span></label>
<button type="submit">Submit</button>
</form>
</div>
如何解析找到2个具有唯一ID的元素"?警告?
How do I resolve "Found 2 elements with non-unique id" warnings?
推荐答案
只需使用新的{id =" },用于以下两个字段之一:
Just use new { id = "" } for one of the two fields:
@Html.HiddenFor(m => m.Name, new { id = "" })
这篇关于找到2个具有非唯一ID的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文