Chrome发现DOM错误2元素非唯一ID,输入类型为password

时间:2019-01-16 10:19:05

标签: javascript jquery asp.net-mvc

2输入类型密码HTML标签我在我的表单中使用它会给我错误非唯一ID。我为两个不同的标签赋予了不同的ID

我的代码

 <div id="Authdialog-message" title="Authorization" style="display: none">
    <label>PassWord :</label>
    <input id="AuthPwD"  type="password" name="Pwd" class="TextBxFormat"  style="width: 200px; margin-left: 5px;">
 </div>

 <div id="AdminstRemark" title="Add Remark" style="display: none">
    <label>PassWord </label>
    <input id="RmkAuthPwD" type="password" name="Pwd1" class="TextBxFormat Mandatory" style="width: 200px; margin-left: 5px;">
 </div>

但是当我在下面注释这两行代码

<input id="AuthPwD"  type="password" name="Pwd" class="TextBxFormat"   
                              style="width: 200px; margin-left: 5px;">
<input id="RmkAuthPwD" type="password" name="Pwd1" class="TextBxFormat Mandatory" 
                             style="width: 200px; margin-left: 5px;">

错误消失

1 个答案:

答案 0 :(得分:0)

在页面上查找非唯一ID可能对您有所帮助。

document.querySelectorAll('[id=test]');

或使用jQuery:

$('[id=test]');

只需console.log这样的非唯一ID:

console.log( $('[id=hello]')); // hello - your non-unique id