【发布时间】:2021-01-24 04:40:26
【问题描述】:
当我们在两个不同的 form 标签中使用相同的 id 名称时,我收到以下警告。
[DOM] 找到 2 个具有非唯一 id 的元素
这是我的 HTML sn-p:
<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 的元素”警告?
【问题讨论】:
-
使 ID 唯一?
标签: javascript html jquery bootstrap-4 html5-video